-
Notifications
You must be signed in to change notification settings - Fork 66
Scissors - Mariela Cruz #41
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
CheezItMan
left a comment
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 Mariela, you hit the learning goals here. Well done.
I left some minor comments, but this is a solid submission. Let me know what questions you have.
| # Time Complexity: O(1) | ||
| # Space Complexity: O(n) | ||
| 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: 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.
👍
| current = self.head | ||
| if self.head == None: | ||
| self.head = Node(value) | ||
| self.tail = self.head | ||
| self.size += 1 | ||
| else: | ||
| new_node = Node(value) | ||
| new_node.next = current | ||
| current.previous = new_node | ||
| self.head = new_node | ||
| self.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.
Could be more compact
| current = self.head | |
| if self.head == None: | |
| self.head = Node(value) | |
| self.tail = self.head | |
| self.size += 1 | |
| else: | |
| new_node = Node(value) | |
| new_node.next = current | |
| current.previous = new_node | |
| self.head = new_node | |
| self.size += 1 | |
| self.head = Node(value, self.head) | |
| self.size += 1 | |
| if self.tail is None: | |
| self.tail = self.head |
| # 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: O(1) | ||
| # 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.
👍
| if self.head == None: | ||
| self.head = new_node | ||
| self.tail = self.head | ||
| self.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.
In this scenario, you could also call self.add_first
| # testing? | ||
| # 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: O(n) | ||
| # Space Complexity: O(1) | ||
| 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: O(n) | ||
| # Space Complexity: O(1) | ||
| 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.
👍
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| 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.
👍
No description provided.