-
Notifications
You must be signed in to change notification settings - Fork 414
Spruce - Michelle Morales #15
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?
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.
🤠💫 Very solid implementation, Michelle! Make sure you fork against the C16 version instead of AdaGold next time! Let me know what questions you have.
🟢
| self.size = 0 | ||
|
|
||
|
|
||
| def enqueue(self, 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.
✨
| self.rear = (self.rear + 1) % self.buffer_size | ||
| self.size += 1 | ||
|
|
||
| def dequeue(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.
✨
| self.rear = -1 | ||
| return value | ||
|
|
||
| def front(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.
✨
| self.buffer_size = INITIAL_QUEUE_SIZE | ||
| self.front = -1 | ||
| self.rear = -1 | ||
| self.rear = 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.
There's not really anything wrong with initializing this to 0, but since you reset it to '-1' in dequeue below when the queue becomes empty, it's best to stay consistent across the board.
| self.rear = 0 | |
| self.rear = -1 |
| if self.front == -1: | ||
| return 0 | ||
| 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.
Since size should already be 0 if the queue is empty, you can probably delete lines 65 - 66.
| if self.front == -1: | |
| return 0 | |
| return self.size | |
| return self.size |
| for x in range(size): | ||
| result.append(self.store[index]) | ||
| index = (index + 1) % self.buffer_size | ||
| size -= 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.
We generally try not to change the value we are iterating through, and it's not necessary to modify size here.
| size -= 1 |
| Returns None | ||
| """ | ||
| pass | ||
| 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.
✨
| returns None | ||
| """ | ||
| pass | ||
| 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.
✨
| And False otherwise | ||
| """ | ||
| pass | ||
| return self.store.empty() |
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.
✨
| ending with the bottom of the Stack. | ||
| """ | ||
| pass | ||
| return str(self.store) |
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