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

Leaves - Dominique #43

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

Leaves - Dominique #43

wants to merge 4 commits into from

Conversation

dtaylor73
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? It is a type of object which is described by the methods it has and how they perform. Implementation details are not included
Describe a Stack A Stack is a data structure which stores a list of data and only provides access in a Last-In-First-Out (LIFO) order.
What are the 5 methods in Stack and what does each do? Push (put data on the top of the stack), pop (delete data from the top of the stack), is_empty? (returns true if the stack is empty)
Describe a Queue A queue unlike a stack operates in a first-in-first out order. Like a line of people at a concert, the first element to enter the queue is the first element removed.
What are the 5 methods in Queue and what does each do? Enqueue (adds data to the back of the queue), dequeue (removes data from the front of the queue), front (returns the data at the front of the queue), size (returns the length of the queue), empty (returns true if the queue is empty)
What is the difference between implementing something and using something? A queue using an array, but the array is doing the 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.

Nice work, you hit the learning goals here. Well done. Take a look at my comments and let me know if you have questions.

raise NotImplementedError, "Not yet implemented"
@store = Array.new(100)
@front = @back = -1
@data = ''

Choose a reason for hiding this comment

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

Data?

@store = Array.new(100)
@front = @back = -1
@data = ''
# - 1 gets put into @back and the value of @back is put into @front
end

def enqueue(element)

Choose a reason for hiding this comment

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

👍

end
end



def dequeue

Choose a reason for hiding this comment

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

👍

end
return value
end

end

def front

Choose a reason for hiding this comment

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

👍

end

def size
raise NotImplementedError, "Not yet implemented"
return @store.length

Choose a reason for hiding this comment

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

This only gives the size of the internal array size, not the number of elements in the Queue.

Comment on lines +51 to +53
return true if @front == @back

return false

Choose a reason for hiding this comment

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

Suggested change
return true if @front == @back
return false
return @front == @back

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