-
Notifications
You must be signed in to change notification settings - Fork 44
Diana - Space #27
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
base: master
Are you sure you want to change the base?
Diana - Space #27
Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diana, nice work. You hit the main learning goals. Well done.
| # Time Complexity: O(n), will always have to traverse through the string | ||
| # Space Complexity: O(n), because in the worst case all char in string | ||
| # are opening brackets, best case would be O(1) where we push and pop every item | ||
| def balanced(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , However you can dry up the case statement by using a hash instead. The has would have the open braces as the keys and the closing braces as the values.
return false if brace_hash[current_char] != char| @back = 0 | ||
| end | ||
|
|
||
| def enqueue(element) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| def front | ||
| raise NotImplementedError, "Not yet implemented" | ||
| @front |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @front | |
| @store[@front] |
| def size | ||
| raise NotImplementedError, "Not yet implemented" | ||
| @size | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size should be the number of elements in the queue. You can calculate it using the position of front and rear.
| @@ -1,19 +1,20 @@ | |||
| class Stack | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
-pop: remove element
-is_empty: check if stack is empty
-initialize: create LinkedList base for stack
-to_s: allow for easy to read output of stack
-dequeue: removes element from front of rear
-is_empty?: checks if queue is empty
-initialize: sets up initial queue
-size: gives size of queue
Use: able to utilize without knowing the logic–application of the something
OPTIONAL JobSimulation