Skip to content

Conversation

@marielaxcruz
Copy link

No description provided.

@marielaxcruz marielaxcruz changed the title Mariela Cruz Scissors - Mariela Cruz Oct 10, 2021
Copy link

@CheezItMan CheezItMan left a 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.

Comment on lines +18 to 20
# Time Complexity: O(1)
# Space Complexity: O(n)
def get_first(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +28 to 30
# Time Complexity: O(1)
# Space Complexity: O(1)
def add_first(self, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +31 to +41
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be more compact

Suggested change
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

Comment on lines +45 to 47
# Time Complexity: O(n)
# Space Complexity: O(1)
def search(self, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +56 to 58
# Time Complexity: O(1)
# Space Complexity: O(1)
def length(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +114 to +117
if self.head == None:
self.head = new_node
self.tail = self.head
self.size += 1

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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +143 to 145
# Time Complexity: O(n)
# Space Complexity: O(1)
def delete(self, value):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +178 to 180
# Time Complexity: O(n)
# Space Complexity: O(1)
def visit(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +192 to 194
# Time Complexity: O(n)
# Space Complexity: O(1)
def reverse(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants