Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kelly #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Kelly #10

wants to merge 3 commits into from

Conversation

kdow
Copy link

@kdow kdow commented Sep 8, 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 types are objects that describe the methods and how they perform, but do not include implementation details.
Describe a Stack Stacks are data structures that store a list where items follow LIFO.
What are the 5 methods in Stack and what does each do? 1. initialize: creates a list in the chosen data structure to be the stack. 2. push: This will add an element to the top of the stack. 3. pop: This will remove an element from the top of the stack. 4. empty?: This will check whether the stack is empty or not. 5. to_s: this will return the values of the stack in a string.
Describe a Queue Queues are data structures that store a list where items follow FIFO.
What are the 5 methods in Queue and what does each do? 1. initialize: create a list in the chosen data structure that will be the queue. 2. enqueue: This will add an element to the back of the queue. 3. dequeue: this will remove an element from the front of the queue. 4. front: This will return the element at the front of the queue. 5. size: This returns this size of the queue. 6. empty?: This will check whether the queue is empty or not. 5. to_s: this will return the values of the queue in a string.
What is the difference between implementing something and using something? Implementation requires details on how it will work, while using something doesn't need to know the implementation details, just what it does.

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.

Overall nice work, you hit the learning goals here. Take a look at my comments and let me know where you have questions.

end

def dequeue
raise NotImplementedError, "Not yet implemented"
removed = @store[@front]

Choose a reason for hiding this comment

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

👍

end

def size
raise NotImplementedError, "Not yet implemented"
return @store.size

Choose a reason for hiding this comment

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

This tells you the size of the internal array, not the size of the queue.

end

def to_s
return @store.to_s
store_string = []
@store.each do |num|

Choose a reason for hiding this comment

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

This should start with the front and traverse the array until the rear, including wrapping around the array if needed.

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