Skip to content

Conversation

@hn4ever
Copy link

@hn4ever hn4ever commented Apr 22, 2021

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? A type of object where it's described by its methods.
Describe a Stack A data structure in which stores a list of data that can only be accessed in 'Last In First Out' order.
What are the 5 methods in Stack and what does each do? They are: push (to add an item at the top), pop (to remove an item from the top), is_empty(to check if the stack is empty), peek (return the value of the top item without removing it), size (return the number of items in the stack)
Describe a Queue A type of data structure in which stores a list of data that are only accessible in a 'First In First Out' Order.
What are the 5 methods in Queue and what does each do? They are: enqueue (to add an item at the back of the queue, dequeue (to remove an item from the front of the queue), is_empty (checks if a queue is empty or not), front (return the value of the front item without removing it), and size (return number of items in a queue
What is the difference between implementing something and using something? If we use something, we will not need to know how it was implemented, while if we implement something we need to know most of its use cases.

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.

Well done Noor, you hit the learning goals here. Well done.

@front = @back = 0
end

def enqueue(element)

Choose a reason for hiding this comment

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

👍

@back = (@back + 1) % Array_Length
end

def dequeue

Choose a reason for hiding this comment

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

👍 , very compact, nicely done!

return @store[@front]
end

def size

Choose a reason for hiding this comment

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

👍

end
end

def empty?

Choose a reason for hiding this comment

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

👍

@@ -1,19 +1,20 @@
class Stack

Choose a reason for hiding this comment

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

👍

@hn4ever
Copy link
Author

hn4ever commented May 11, 2021

Thank you Chris :)

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