Skip to content

Kelly#10

Open
kdow wants to merge 3 commits intoAda-C11:masterfrom
kdow:master
Open

Kelly#10
kdow wants to merge 3 commits intoAda-C11:masterfrom
kdow:master

Conversation

@kdow
Copy link
Copy Markdown

@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
Copy Markdown

@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.

Comment thread lib/queue.rb

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

Choose a reason for hiding this comment

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

👍

Comment thread lib/queue.rb

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

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.

Comment thread lib/queue.rb
def to_s
return @store.to_s
store_string = []
@store.each do |num|
Copy link
Copy Markdown

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