Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaves - Emily V #40

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Leaves - Emily V #40

wants to merge 5 commits into from

Conversation

emilyvomacka
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 structure: methods are public, implementation is private
Describe a Stack LIFO: like a stack of books on a shelf.
What are the 5 methods in Stack and what does each do? push: add an element to the top of the stack. pop: remove an element from the top of the stack. empty: describes whether the stack is empty. (seems like we only implemented 3)
Describe a Queue FIFO: like standing in line for the bus.
What are the 5 methods in Queue and what does each do? enqueue: add to the back of the line. dequeue: remove from the front of the line. front: preview the next element to be dequeued without dequeueing it. size: return the size of the queue. empty? return whether there are zero elements in the queue.
What is the difference between implementing something and using something? Implementing: building a mechanism to achieve your goals. Using: putting someone else's mechanism to work for you.

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.

Overall nice work, you hit the main learning goals here. Take a look at my comments and let me know if you have any questions. Well done.

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.

👍

Comment on lines +30 to 32
# Time Complexity: O(n)
# Space Complexity: O(n) <- but we'd probably use less assuming the expression contains operators
def evaluate_postfix(postfix_expression)

Choose a reason for hiding this comment

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

👍

end


def enqueue(element)

Choose a reason for hiding this comment

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

This method could use being broken into some helper methods. Otherwise it seems to work.

raise NotImplementedError, "Not yet implemented"
#resize if the array is full
if @front == (@back + 1) % @store.length
temp = Array.new(@store.length + 1)

Choose a reason for hiding this comment

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

Why make it one bigger? That gets pretty expensive in terms of time.

def size
raise NotImplementedError, "Not yet implemented"
return abs(@back - @front + 1)

Choose a reason for hiding this comment

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

This only works if @back > @front

end


def to_s

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