-
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 - Rhyannon Rodriguez #72
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 Rhyannon! I left one comment about the time complexity of get_first
. Let me know what questions you have.
🟢
@@ -13,83 +12,161 @@ def __init__(self): | |||
|
|||
# returns the value in the first node | |||
# returns None if the list is empty | |||
# Time Complexity: ? | |||
# Space Complexity: ? | |||
# Time Complexity: Linear O(N), size of LL |
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 would actually be O(1) here, because you only ever need to look at the head of the list.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: Adding a head, Constant O(1) | ||
# Space Complexity: Constant O(1) not creating new data structure | ||
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: Linear O(N), size of the LL | ||
# Space Complexity: Constant O(1), we're not creating data structures | ||
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: Linear O(N), size of the LL | ||
# Space Complexity: Constant O(1), we're not creating data structures | ||
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: Linear O(N), size of the LL | ||
# Space Complexity: Constant O(1), we're not creating data structures | ||
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.
✨
current = self.head | ||
while current.next: | ||
current = current.next | ||
current.next = new_node | ||
|
||
# method to return the max value in the linked list | ||
# returns the data value and not the node | ||
def find_max(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: Linear O(N), size of the LL | ||
# Space Complexity: Constant O(1), we're not creating data structures | ||
def delete(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: Linear O(N), size of the LL | ||
# Space Complexity: Linear O(N), depending on the size of the visited_list | ||
def visit(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 visit(self): | ||
helper_list = [] | ||
visited_list = [] | ||
current = self.head | ||
|
||
while current: |
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: Linear O(N), depending on the size of the LL | ||
# Space Complexity: Constant O(1), no creation of new data structures | ||
def reverse(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.
✨
Only required exercises completed