-
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
C16 - Spruce - Vange Spracklin #46
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 nice work, Vange! I left a couple small suggestions, but overall your implementation is solid.
I am grading this as a yellow because you did not attempt the comprehension questions, but a yellow is a passing score. If you would like to resubmit with the comprehension questions filled in, I'd happily up this to a green!
🟡
@@ -15,47 +15,78 @@ def __init__(self): | |||
self.front = -1 | |||
self.rear = -1 | |||
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.store[self.rear] = element | ||
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.
✨
|
||
def front(self): | ||
""" Returns an element from the front | ||
of the Queue and None if the Queue | ||
is empty. Does not remove anything. | ||
""" | ||
pass | ||
if self.size == 0: | ||
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.
🤔 Looks like you forgot to return here. As it stands, you basically state the name of a literal None
and then it floats away into the ether ☁
None | |
return None |
|
||
def front(self): | ||
""" Returns an element from the front | ||
of the Queue and None if the Queue | ||
is empty. Does not remove anything. | ||
""" | ||
pass | ||
if self.size == 0: | ||
None | ||
return self.store[self.front] | ||
|
||
|
||
def size(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.
✨
|
||
|
||
def size(self): | ||
""" Returns the number of elements in | ||
The Queue | ||
""" | ||
pass | ||
return self.size | ||
|
||
def empty(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.
✨
@@ -12,7 +12,8 @@ def push(self, element): | |||
""" Adds an element to the top of the Stack. | |||
Returns None | |||
""" | |||
pass | |||
self.store.add_last(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.
✨
@@ -12,7 +12,8 @@ def push(self, element): | |||
""" Adds an element to the top of the Stack. | |||
Returns None | |||
""" | |||
pass | |||
self.store.add_last(element) | |||
return 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.
Small style tip: If a function always returns None
, I'd recommend returning None
implicitly by just not having any return value (functions in Python return None
by default).
return None |
@@ -12,7 +12,8 @@ def push(self, element): | |||
""" Adds an element to the top of the Stack. | |||
Returns None | |||
""" | |||
pass | |||
self.store.add_last(element) | |||
return None | |||
|
|||
def pop(self): | |||
""" Removes an element from the top |
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: | ||
return None | ||
return self.store.remove_last() | ||
# return None | ||
|
||
def empty(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.
✨
|
||
def __str__(self): | ||
""" Returns the Stack in String form like: | ||
[3, 4, 7] | ||
Starting with the top of the Stack and | ||
ending with the bottom of the Stack. | ||
""" | ||
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.
✨ Nice! You could also take 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