-
Notifications
You must be signed in to change notification settings - Fork 41
Fire - Ida #29
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?
Fire - Ida #29
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.
Nice work Ida, I had a few comments on the Queue. Take a look at my comments and let me know what questions you have.
| @@ -0,0 +1,15 @@ | |||
| { | |||
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.
This could be added to .gitignore
|
|
||
| end | ||
|
|
||
| def dequeue |
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.
👍
| @@ -1,19 +1,23 @@ | |||
| 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.
👍
| elsif (@front == @size-1) | ||
| @front = 0 | ||
| else | ||
| @front = @front + 1 | ||
| 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.
This will let front wrap around without having to make the elif-else.
| elsif (@front == @size-1) | |
| @front = 0 | |
| else | |
| @front = @front + 1 | |
| end | |
| else | |
| @front = (@front + 1) % @store.length | |
| end |
| @rear += 1 | ||
| @queue[@rear] = 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.
This lets the rear wrap around
| @rear += 1 | |
| @queue[@rear] = element | |
| @rear = (@rear + 1) % @store.length | |
| @queue[@rear] = element |
Co-authored-by: Chris M <chris@adadevelopersacademy.org>
Co-authored-by: Chris M <chris@adadevelopersacademy.org>
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
push- adds an element to the end of the stackpop- removes and returns the item on the top of the stack.is_empty- checks if a stack is emptyenqueue- adds element to the back of the queue,dequeue- removes element from the front,is_empty- returns true if queue is empty, false if it isn'tOPTIONAL JobSimulation