Skip to content

Conversation

@Jing-321
Copy link

@Jing-321 Jing-321 commented Apr 15, 2021

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 Stack ADT allows all data operations at one end only. At any given time, we can only access the top element of a stack
What are the 5 methods in Stack and what does each do? initialize: initialize a stack. push: add an element to the top of the stack. pop: remove the element on the top of the stack.
Describe a Queue In a queue data structure, adding and removing elements are performed at two different positions. The insertion is performed at one end and deletion is performed at another end.
What are the 5 methods in Queue and what does each do? initialize: initialize a queue. enqueue: add an element to the @Head of a queue. dequeue: remove the element from the @tail of a queue.
What is the difference between implementing something and using something?

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.

This is really good work Jing. You hit the learning goals here. Well done.

I had one comment on dequeue, let me know if you have questions on it.

@size += 1
end

def dequeue

Choose a reason for hiding this comment

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

What about if @size is 0?

return @size == 0
end

def to_s

Choose a reason for hiding this comment

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

Well done!

@@ -1,19 +1,21 @@
require_relative './linked_list.rb'

class Stack

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