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 M #15

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

Ports - Amy M #15

wants to merge 3 commits into from

Conversation

amyesh
Copy link

@amyesh amyesh commented Sep 9, 2019

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 is a type of data structure where methods are public, but the underlying data structure is hidden. ADTs have required functions in their external interface, but their internal implementation is determined by the creator.
Describe a Stack Stacks are ADT's that operate on a first in last out principle.
What are the 5 methods in Stack and what does each do? initialize creates a new LinkedList object. Push uses the LinkedList method .add_last to add an element to the end of the list. Pop implements the LinkedList method .remove_last to remove the last element and return the value. Empty? returns true if the stack is empty and false if not. To to_s method turns turns the stack, or linked list into an array, and then returns that array as a string
Describe a Queue Queues are ADT's that operate on a first in first out principle.
What are the 5 methods in Queue and what does each do? Initialize - creates a new queue with a constant size of 20, enqueue adds an element to the end of the queue, if there's space, dequeue removes the first element in the queue and returns that element, front returns the front element without removing it, size returns the number of truthy elements in the queue, and to_s returns the queue as a string.
What is the difference between implementing something and using something? Implementation is when you design the functionality of something, and using something is when you actually execute that implementation.

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.

Really great work! You hit all the learning goals here. Well done!


def balanced(string)
raise NotImplementedError, "Not implemented yet"
parens_hash = {

Choose a reason for hiding this comment

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

Nice use of a hash!

end

def dequeue
raise NotImplementedError, "Not yet implemented"
if @front == -1

Choose a reason for hiding this comment

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

Great work !

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 gives you the size of the array, not the size of the queue.

end

def empty?
raise NotImplementedError, "Not yet implemented"
@front == -1 ? true : false
end

def to_s

Choose a reason for hiding this comment

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

Great work!

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