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

Sarah #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Sarah #17

wants to merge 1 commit into from

Conversation

sjscotton
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? ADT is Abstract Data type. The is a datatype that has a specific interface, but the implementation does not matter so long as it has the correct behavior.
Describe a Stack A stack is a first in last out model. The first item added will the the last removed, and the last added will be the first removed.
What are the 5 methods in Stack and what does each do? 1. Initialize, it just starts a new instance of the stack data type. 2. push, adds a new item to the top of the data. 3. Pop, removes the last item added to the stack. 4. empty, returns true of the stack is empty, false otherwise. 5. to_s, returns a human readable string representation of the data
Describe a Queue A queue is a first in last out data model. The first item added will be the first item removed.
What are the 5 methods in Queue and what does each do? 1. Initialize, it just starts a new instance of the stack data type. 2. enqueue, adds an item to the back of the queue, 3. Dequeue, removes the item at the front of a queue. 4. empty, returns true of the queue is empty, false otherwise. 5. to_s, returns a human readable string representation of the data
What is the difference between implementing something and using something? Implementing is writing the methods that describe the behavior, and using is using a behavior that already exists.

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.

Outstanding work, You hit all the learning goals here. Well done.


def balanced(string)
raise NotImplementedError, "Not implemented yet"
stack = Stack.new
pairs = { ")" => "(", "]" => "[", "}" => "{" }

Choose a reason for hiding this comment

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

Good use of a hash!

value = @store[@front]
@store[@front] = nil
@front = (@front + 1) % QUEUE_SIZE
@front = @rear = -1 if @front == @rear

Choose a reason for hiding this comment

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

👍

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