Skip to content

Conversation

@corinna-fab
Copy link

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? An Abstract Data Type is a data type that is defined by its behavior, not by its implementation.
Describe a Stack A linear data structure with a last-in-first-out (LIFO) order.
What are the 5 methods in Stack and what does each do? Initialize, push (adds an element to the end), pop (removes the last element), empty? (which checks to see if the stack is empty), and to_s (which returns the list as a string).
Describe a Queue A linear data structure with a first-in-first-out (FIFO) order.
What are the 5 methods in Queue and what does each do? Initialize, enqueue (adds an element to the end), dequeue (removes the first element/current head), front (which returns the first element), size (length of the list), empty? (checks to see if the queue is empty), and to_s.
What is the difference between implementing something and using something? Implementing refers to defining the structure and functions of your data structure, whereas using refers to the use of a data structure.

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the code works and you hit many of the requirements. However you did not implement the Queue with a circular buffer. Instead you implemented it using a straight array. The tests pass, because it functions, but the implementation isn't what was assigned. Otherwise well done.

Comment on lines +3 to 5
# Time Complexity: O(n) -- where n is characters in string
# Space Complexity: O(n) -- where n is characters in string
def balanced(string)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -1,28 +1,33 @@
class Queue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but you were asked to implement this using a circular buffer. I think you missed a bit about the point of the assignment and the last part of last week's class.

@@ -1,19 +1,20 @@
class Stack

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants