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

vi #42

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

vi #42

wants to merge 2 commits into from

Conversation

criacuervos
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, which is defined by its behavior (what it does) rather than how it is written (implementation)
Describe a Stack a data structure that stores a list of data and only allows access in a LIFO manner
What are the 5 methods in Stack and what does each do? push puts an item on the top, pop removes and returns the item that was on top, is_empty returns true if the stack is empty, peek returns (without removing) the top item on the stack, and size returns the number of items in the stack.
Describe a Queue a data structure that stores a list of data and allows access in a FIFO, first in first out, manner
What are the 5 methods in Queue and what does each do? enqueue adds a value to the back of a queue, dequeue removes and returns the value from the front, is_empty returns true if empty, front returns the value at the start of a queue, and size returns the total amount of items in the queue
What is the difference between implementing something and using something? when you implement something you've got to know intricately how it works; say we're implementing a linked list. a part of doing that is knowing how a linked list works, writes to memory, stores data. however, if we were using a method to for example, add a data to a list, we often don't need to even know the data structure involved in doing that.

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.

Well Stack is working and what you have in Queue is pretty well done, but several methods are not implemented further. Not bad, but there is more to do.

#Check if queue is empty
if @front == -1 && @back == -1
@front = 0
@back = 1

Choose a reason for hiding this comment

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

Since you're going to advance @back one step later in this method better to set it to 0


@front = (@front + 1) % @store.length

return temp
end

Choose a reason for hiding this comment

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

Other methods are missing here.

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