Conversation
kyra-patton
left a comment
There was a problem hiding this comment.
✨🌸 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 |
| The Queue is empty. | ||
| """ | ||
| pass | ||
| if self.front == -1: |
There was a problem hiding this comment.
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] |
| The Queue | ||
| """ | ||
| pass | ||
| return self.size |
| And False otherwise. | ||
| """ | ||
| pass | ||
| return (self.size == 0) |
| pass | ||
| return (self.size == 0) | ||
|
|
||
| def __str__(self): |
| if self.store.head == None: | ||
| raise StackEmptyException("The stack is empty") | ||
|
|
||
| return self.store.remove_first() |
There was a problem hiding this comment.
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.
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.
✨ This does work. You could also consider taking advantage of LinkedList's empty method
| else: | ||
| return False | ||
|
|
||
| def __str__(self): |
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation