Skip to content

Conversation

@stpatrickschild
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 structure described by the set of operations it can perform, the details of which are hidden.
Describe a Stack Stack is a type of data structure that implement LIFO.
What are the 5 methods in Stack and what does each do? push(element)- adds an element to the top of the stack, pop - removes and returns the element on top of the stack; is_empty -returns true is the stack has no elements, and false otherwise, peek or top - returns but does not remove the top element of the stack, finally size - returns the number of elements on the stack
Describe a Queue Queue is a data structure that is similar to apple store line, you form 1 line and each person that comes stand behind that last person. The first person also gets help first. So FIFO
What are the 5 methods in Queue and what does each do? enqueue - add something to the Q, dequeue - removes something from the Q, is_empty - is a method that returns bool T if yes and F if not empty, front -returns the element at the front, but leaves the queue unchanged and size - returns the number of elements in the Q
What is the difference between implementing something and using something? Implementing something refers to creating something Implementing requires a lot more knowledge because you need to create it; using you only need to know how it works to get the outcome you want.

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.

Nicely done Hannah. The code works well. In the future take a stab at the time/space complexity. It's good practice. Even guessing wrong is ok.

Comment on lines 3 to -6
# Time Complexity: ?
# Space Complexity: ?
def balanced(string)
raise NotImplementedError, "Not implemented yet"

Choose a reason for hiding this comment

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

👍 Time & space complexity?

Comment on lines 21 to 23
# Time Complexity: ?
# Space Complexity: ?
def evaluate_postfix(postfix_expression)

Choose a reason for hiding this comment

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

👍 Time & space complexity?

raise "Buffer is full"
end
@store[@tail] = element
@tail = (@tail + 1) %20

Choose a reason for hiding this comment

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

Suggestion for less hardcoded lengths.

Suggested change
@tail = (@tail + 1) %20
@tail = (@tail + 1) % @store.length

end
result = @store[@head]
@store[@head] = nil
@head = (@head +1) %20

Choose a reason for hiding this comment

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

Suggested change
@head = (@head +1) %20
@head = (@head +1) @store.length

@stpatrickschild stpatrickschild changed the title all test passed Time - Hannah T Jan 5, 2021
@stpatrickschild stpatrickschild changed the title Time - Hannah T Time - Hannah T. Jan 5, 2021
@stpatrickschild stpatrickschild changed the title Time - Hannah T. Time - Hannah T Jan 5, 2021
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