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

Ports - Amy W #12

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

Ports - Amy W #12

wants to merge 3 commits into from

Conversation

amythetester
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? Abstract data type.
Describe a Stack A data structure that uses first-in-last-out.
What are the 5 methods in Stack and what does each do? Initialize: creates a base Stack. Push: adds a new value to the top of the stack. Pop: removes the value from the top of the Stack. Empty?: returns true if the Stack is empty. To_s: returns a string representation of the Stack.
Describe a Queue A data structure that uses first-in-first-out.
What are the 5 methods in Queue and what does each do? Initialize: creates a base Queue. Enqueue: adds a new value to the end of the Queue. Dequeue: removes the value at the start of the Queue. Empty?: returns true if the Queue is empty. To_s: returns a string representation of the Queue.
What is the difference between implementing something and using something? Implementing is when you are writing the details of how a class and its methods should work. Using is when you call a method that has already been implemented.

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.

Some good work in here, and a few issues. Take a look at my comments and let me know if you have questions. In particular take a look at my comments on the Queue.


def balanced(string)
raise NotImplementedError, "Not implemented yet"
length = string.length

Choose a reason for hiding this comment

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

Question: What about {}(), It is balanced.

if @front == -1
return
else
@front += 1

Choose a reason for hiding this comment

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

Since the front can wrap around the array this should be @front = (@front + 1) % QUEUE_SIZE

You should also check to see if the queue is now empty.

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