-
Notifications
You must be signed in to change notification settings - Fork 87
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
Maple: Sabrina Lauredan #76
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.
✨ Hi Sabrina, I have some concerns about your implementation and you missed implementing the last required function reverse
. Take a look at my comments and let me know what questions you have.
🟡
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(1) | ||
# Space Complexity: O(1) | ||
def get_first(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.
✨
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(1) | ||
# Space Complexity: O(1) | ||
def add_first(self, value): |
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.
✨
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def search(self, value): |
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.
✨
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def length(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.
✨
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(n) | ||
# Space Complexity: 0(1) | ||
def get_at_index(self, index): |
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.
✨
index = 0 | ||
current = self.head | ||
prev = self.head | ||
temp = self.head | ||
while current is not None: | ||
if index == value: |
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.
Same thing here you are checking to see if the node's value attribute is equal to the passed in value
, not to see whether value equals the index of the node.
while current is not None: | ||
if index == value: | ||
temp = current.next | ||
break |
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 like to avoid break statements where possible. How might you refactor your code to eliminate this break statement?
current = current.next | ||
index += 1 | ||
prev.next = temp | ||
return prev |
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.
It's not necessary to return anything for this function
return prev |
# Time Complexity: O(n) | ||
# Space Complexity: O(n) |
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.
✨
# Time Complexity: ? | ||
# Space Complexity: ? | ||
def reverse(self): | ||
pass |
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.
No description provided.