Skip to content

Earth/Taylor#22

Open
TaylorMililani wants to merge 1 commit into
Ada-C14:masterfrom
TaylorMililani:master
Open

Earth/Taylor#22
TaylorMililani wants to merge 1 commit into
Ada-C14:masterfrom
TaylorMililani:master

Conversation

@TaylorMililani
Copy link
Copy Markdown

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 collection of elements where the last element to be added will be the first to be removed (LIFO)
What are the 5 methods in Stack and what does each do? push adds an element to the top of the stack, pop removes the top element, empty checks if the stack is empty, full? checks if stack is full, peek gets element at top of stack without returning it.
Describe a Queue a collection where the first element added will be the first to be removed. (FIFO)
What are the 5 methods in Queue and what does each do? Enqueue adds an element to the queue, dequeue removes and returns an element, peek gets the element at the front without returning it, full? - checks if queue is full, empty? - checks if queue is empty
What is the difference between implementing something and using something? implementing means to create it, using it puts it into practice.

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

Copy link
Copy Markdown

@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 Taylor, you hit the learning goals here. Well done.

Comment thread lib/problems.rb
Comment on lines +3 to 5
# Time Complexity: O(nlogn)
# Space Complexity: O(n)
def balanced(string)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since you have to go through all the chars and you're not splitting at each stage, this is O(n) for time complexity.

Comment thread lib/problems.rb
Comment on lines +10 to +12
if chars.include?(char)
stack.push(char)
else
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you do this with a hash where the keys are the open brace and he values are the matching close brace? That might help you dry up those if-else statements.

Comment thread lib/problems.rb
Comment on lines +26 to 28
# Time Complexity: O(n)
# Space Complexity: O(n)
def evaluate_postfix(postfix_expression)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Interesting use of eval

Comment thread lib/queue.rb
(@end + 1) % @size == @start
end

def enqueue(element)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/queue.rb
end
end

def dequeue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/queue.rb
@@ -1,31 +1,65 @@
class Queue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Well done!

Comment thread lib/stack.rb
@@ -1,22 +1,24 @@
require_relative 'linked_list'

class Stack
Copy link
Copy Markdown

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