Skip to content

Conversation

@quinqu
Copy link

@quinqu quinqu commented Sep 9, 2020

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 stack is an ADT in which elements are FILO
What is the difference between implementing something and using something? If you implement, create it with and know what is under the hood, using; you generally don't know what's going on in the background
Describe a Queue a queue is FIFO

What are the 5 methods in Stack and what does each do?

  • initialize initializes the stack (under the hood a linked list)
  • push(data) adds data to the stack (end of a linked list)
  • pop() removes the most recently added element
  • empty? checks if the stack is empty (t/f)
  • to_s prints the stack

What are the 5 methods in Queue and what does each do?

  • initialize initializes the stack (under the hood a linked list)
  • enqueue adds data to the queue (end of a linked list)
  • dequeue removes data from the queue (front of a linked list)
  • front get the data that is first in the queue
  • size size of the queue
  • empty? checks if the queue is empty (t/f)
  • to_s prints the queue

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.

You didn't implement the Queue with a circular buffer. Instead you used a linked list. Other than that you hit the rest of the learning goals here.

Comment on lines +3 to 5
# Time Complexity: O(n)
# Space Complexity: O(n)
def balanced(string)

Choose a reason for hiding this comment

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

👍

@@ -1,31 +1,32 @@
require './linked_list'

class Queue

Choose a reason for hiding this comment

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

This works, but it's not implemented using a circular buffer, so it's not what was asked for.

@@ -1,22 +1,23 @@
require './linked_list'

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