Skip to content

Earth - Sophie#19

Open
steve-messing wants to merge 4 commits intoAda-C14:masterfrom
steve-messing:master
Open

Earth - Sophie#19
steve-messing wants to merge 4 commits intoAda-C14:masterfrom
steve-messing:master

Conversation

@steve-messing
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? an Abstract Data Type hides the inner structure and design of a data type, and is defined by its behavior for the user
Describe a Stack Last in first out like a stack of plates
What are the 5 methods in Stack and what does each do? initialize, push, pop, empty?, to_s
Describe a Queue first in, first out like a line at the grocery store
What are the 5 methods in Queue and what does each do? initialize, enqueue, dequeue, front, size, empty?, to_s
What is the difference between implementing something and using something? we can use stacks and queues because they are built in data types. It's unusual to have to implement them from scratch

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.

I gave feedback on the matching parens problem. The Queue wasn't done with a circular buffer so it really isn't what was asked. Otherwise well done.


# unfinished not passing, but can you give some feedback on my approach

def balanced(string)

Choose a reason for hiding this comment

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

Maybe set up a dictionary where the keys are the close markers ), }, ] and the values are the matching open characters. Then you can do if the current character isn't a key in the hash you can push it onto the stack, if it IS a close character, you can then compare

return false if char_hash[char]  != stack.pop()

@@ -1,28 +1,29 @@
class Queue

def initialize

Choose a reason for hiding this comment

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

The Queue is supposed to be done with a circular buffer so...

@@ -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.

👍

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