-
Notifications
You must be signed in to change notification settings - Fork 49
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 - Mariya #38
base: master
Are you sure you want to change the base?
Leaves - Mariya #38
Conversation
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.
Overall not bad, some minor issues with Queue. Otherwise it's pretty well done. Nice work
front_array = @store.slice(0, @front) | ||
back_array = @store.slice(@back, @store.length - 1) | ||
@store = front_array + Array.new(10) + back_array | ||
@front = (@front + 10) % @store.length | ||
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 assumes that front is less than back
removed = @store[@front] | ||
@store[@front] = nil | ||
@front = (@front + 1) % @store.length | ||
return removed |
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.
You should also check if the queue is now empty.
if @front == @back | ||
return true | ||
else | ||
return false | ||
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.
if @front == @back | |
return true | |
else | |
return false | |
end | |
return @front == @back |
end | ||
|
||
|
||
def to_s |
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
| Describe a Stack | an ADT where elements that are last in, are first out |
| What are the 5 methods in Stack and what does each do? |
| Describe a Queue | ADT where first element in is the first element out |
| What are the 5 methods in Queue and what does each do? |
| What is the difference between implementing something and using something? | Implementing is like creating the code/function (e.g., a stack class), but using it requires calling on the implemented code to perform actions. Implementation is the creation of something, which needs to be done prior to using/utilizing that code. |
OPTIONAL JobSimulation