Skip to content

Conversation

@sarabrandao21
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? abstract data type only mentions what operations are to be performed but not how these operations will be implemented.
Describe a Stack stack is a linear structure where two operation are allowed: push the item into the stack, and pop the item out of the stack
What are the 5 methods in Stack and what does each do? push where it adds a new element on top of stack, pop removes first or recente element of stack, initializes a new object of a class Stack, empty? it will check if the stack is empty, to_s it returns stack elements as a string
Describe a Queue a queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence
What are the 5 methods in Queue and what does each do? enqueue add to the rear/back, dequeue it removes the element which was added first, front shows the first element without dequeueing it, size will return size(how many elements there are) of the Queue, empty? - checks if the queue is empty
What is the difference between implementing something and using something? an implementation is a realization of an algorithm where you know how it works, using something does not require knowing how it works as long as it gives you the desired outcome.

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 Sara. You hit the learning goals here. Well done.

Comment on lines +13 to +15
elsif brackets.values.include?(char)
return false if brackets.key(char) != stack.pop
end

Choose a reason for hiding this comment

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

Suggested change
elsif brackets.values.include?(char)
return false if brackets.key(char) != stack.pop
end
else
return false if brackets[char] != stack.pop
end


def enqueue(element)
raise NotImplementedError, "Not yet implemented"
def enqueue(element) #move back to the next free position

Choose a reason for hiding this comment

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

👍


def dequeue
raise NotImplementedError, "Not yet implemented"
def dequeue #move front one position clockwise

Choose a reason for hiding this comment

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

👍

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.

👍 Well done here

@@ -1,19 +1,22 @@
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