-
Notifications
You must be signed in to change notification settings - Fork 64
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
Roza-Cedar, re-submission including comprehension questions #38
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.
✨💫 Nice work! I left a couple of suggestions. Great job on the comprehension questions. Let me know what questions you have.
🟢
@@ -23,39 +27,68 @@ def enqueue(self, element): | |||
In the store are occupied | |||
returns None | |||
""" | |||
pass | |||
if self.size == self.buffer_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.
✨
|
||
def dequeue(self): | ||
""" Removes and returns an element from the Queue | ||
Raises a QueueEmptyException if | ||
The Queue is empty. | ||
""" | ||
pass | ||
if self.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.
✨
|
||
def front(self): | ||
""" Returns an element from the front | ||
of the Queue and None if the Queue | ||
is empty. Does not remove anything. | ||
""" | ||
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.
✨
|
||
|
||
def size(self): | ||
""" Returns the number of elements in | ||
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.
✨
|
||
def empty(self): | ||
""" Returns True if the Queue is empty | ||
And False otherwise. | ||
""" | ||
pass | ||
return self.front == self.rear |
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 check if the queue is empty, but it could also mean the queue
while (start_index % INITIAL_QUEUE_SIZE) < INITIAL_QUEUE_SIZE and len(queue_list) < self.size: | ||
if self.store[start_index % INITIAL_QUEUE_SIZE] is not None: | ||
queue_list.append(self.store[start_index % INITIAL_QUEUE_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.
I would recommend using self.buffer_size
instead of the constants for style reasons. It will also allow us to expand our queue functionality in the future, say if we wanted to increase buffer_size
instead of just raising an error.
while (start_index % INITIAL_QUEUE_SIZE) < INITIAL_QUEUE_SIZE and len(queue_list) < self.size: | |
if self.store[start_index % INITIAL_QUEUE_SIZE] is not None: | |
queue_list.append(self.store[start_index % INITIAL_QUEUE_SIZE]) | |
while (start_index % self.buffer_size) < self.buffer_size and len(queue_list) < self.size: | |
if self.store[start_index % self.buffer_size] is not None: | |
queue_list.append(self.store[start_index % self.buffer_size]) |
@@ -12,27 +12,35 @@ def push(self, element): | |||
""" Adds an element to the top of the Stack. | |||
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.
✨
def pop(self): | ||
""" Removes an element from the top | ||
Of the Stack | ||
Raises a StackEmptyException if | ||
The Stack is empty. | ||
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.
✨
|
||
def empty(self): | ||
""" Returns True if the Stack is empty | ||
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.
✨
|
||
def empty(self): | ||
""" Returns True if the Stack is empty | ||
And False otherwise | ||
""" | ||
pass | ||
return self.store.empty() | ||
|
||
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.
✨ This works, but you might also consider taking advantage of LinkedList
's str()
method
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation