Skip to content

Ports - Amy M#15

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

Ports - Amy M#15
amyesh wants to merge 3 commits intoAda-C11:masterfrom
amyesh:master

Conversation

@amyesh
Copy link
Copy Markdown

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

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

Comment thread lib/problems.rb

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

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!

Comment thread lib/queue.rb

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

Choose a reason for hiding this comment

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

Great work !

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

Comment thread lib/queue.rb
@front == -1 ? true : false
end

def to_s
Copy link
Copy Markdown

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