-
Notifications
You must be signed in to change notification settings - Fork 63
Spruce: Kaitlyn #51
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?
Spruce: Kaitlyn #51
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.
✨🌸 Nice work, Kaitlyn. I left a few suggestions and comments, but overall very solid implementations for both classes.
For the comprehension questions, I believe this may have been a typo, but note that a queue is actually first in first out (FIFO) not last in first out (LIFO).
Let me know what questions you have.
🟢
""" Adds an element to the Queue | ||
Raises a QueueFullException if all elements | ||
In the store are occupied | ||
returns None |
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.
😎
The Queue is empty. | ||
""" | ||
pass | ||
if self.front == -1: |
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.
Since you never check after dequeueing an element, whether the queue becomes empty and thus you should move the front
and rear
pointers back to -1, this conditional may not always work. Try using the empty
method you implement below instead.
if self.front == -1: | |
if self.empty(): |
""" | ||
pass | ||
|
||
return self.store[self.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.
✨
The Queue | ||
""" | ||
pass | ||
return self.size |
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.
✨
And False otherwise. | ||
""" | ||
pass | ||
return (self.size == 0) |
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.
✨
pass | ||
return (self.size == 0) | ||
|
||
def __str__(self): |
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 self.store.head == None: | ||
raise StackEmptyException("The stack is empty") | ||
|
||
return self.store.remove_first() |
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.
Per the specification, this should return None
return self.store.remove_first() | |
self.store.remove_first() |
""" | ||
pass | ||
|
||
return self.store.add_first(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.
Per the specification, the function should return None
return self.store.add_first(element) | |
self.store.add_first(element) |
if self.store.head == None: | ||
return True | ||
else: | ||
return False |
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 does work. You could also consider taking advantage of LinkedList
's empty
method
else: | ||
return False | ||
|
||
def __str__(self): |
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
OPTIONAL JobSimulation