Skip to content

Conversation

@yieknee
Copy link

@yieknee yieknee commented Sep 28, 2020

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? An ADT is an abstract data type. An ADT hides the implementation from the user and uses public methods to execute.
Describe a Stack A stack is an ADT with a LIFO system. Elements are added to the stack, and as the last thing added in is finished, it is removed from the stack and the next thing down gets executed.
What are the 5 methods in Stack and what does each do? Initialize- creates a new stack, push- adds an element to the tops of the stack, pop- removes an element from the top of the stack, empty- checks if the stack contains any elements, to_s - converts stack to a string to make it readable
Describe a Queue A queue is an ADT with a FIFO system, where the first element in is the first element out.
What are the 5 methods in Queue and what does each do? Initialize- creates a queue, enqueue- adds element to the back of the queue, dequeue- removes element from the front of the queue, front- checks the element that is at the front, size- checks how many elements are in the queue, empty- checks if the queue has any elements
What is the difference between implementing something and using something? Implementing means building the internal system that will run what you're building. Using means running your syste,

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.

This works, but the Queue wasn't done with a circular buffer as assigned. Take a look at the assignment and the notes and make sure you understand how the circular buffer works before moving on to the next assignment.

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

Choose a reason for hiding this comment

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

This all works, but isn't done with a circular buffer as assigned. So many of the methods end up with O(n) time complexity instead of O(1).

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