Skip to content

Conversation

@aphunk
Copy link

@aphunk aphunk commented Sep 15, 2019

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? Abstract Data Structures are objects that are described by their methods and behaviors, and not by their implementation.
Describe a Stack A stack is a data structure for which its elements can only be accessed in last in, first out order.
What are the 5 methods in Stack and what does each do? 1. Initialize - creates a new stack; 2. Push - adds to the top of the stack; 3. Pop - removes from the top; 4. Empty - determines whether the stack is empty or not; 5. to_s - presents the data in the stack as a string
Describe a Queue A queue is a data structure in which operates in a first in, first out order.
What are the 5 methods in Queue and what does each do? 1. Initialize - creates a new queue; 2. Enqueue - adds to the back of the queue; 3. Dequeue - removes and returns the element from the front of the queue; 4. is_empty - determines whether the queue is empty or not; 5. to_s - presents the data in the queue as a string
What is the difference between implementing something and using something? To implement something is involves applying the behaviors and patterns for that thing; to use something involves the utilization of those behaviors and patterns.

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.

I think you made two PRs, but take a look and let me know any questions you have.

Sorry it took me so long to get to this.

return false
end

list.each do |char|

Choose a reason for hiding this comment

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

This is great!

end
end

def dequeue

Choose a reason for hiding this comment

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

👍

return @store.to_s
elements_in_queue = []
i = @front
while i < @rear

Choose a reason for hiding this comment

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

What if the rear had wrapped around and appears numerically before front?

Maybe instead do until i == @rear

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