Skip to content

all tests passing#66

Open
FaithKauwe wants to merge 1 commit intoAda-C16:masterfrom
FaithKauwe:master
Open

all tests passing#66
FaithKauwe wants to merge 1 commit intoAda-C16:masterfrom
FaithKauwe:master

Conversation

@FaithKauwe
Copy link

No description provided.

@FaithKauwe FaithKauwe closed this Jul 17, 2022
@FaithKauwe FaithKauwe reopened this Jul 17, 2022
Comment on lines 20 to 21
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?

Comment on lines 30 to 31
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?

Comment on lines 40 to 41
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?

Comment on lines 51 to 52
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?

Comment on lines 64 to 65
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?

Comment on lines +95 to +98
while current.next != None:
current = current.next
current.next = new_node
self.tail = current.next

Choose a reason for hiding this comment

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

do we need this while loop? we already have a pointer to the last node because of self.tail, so we can just do this:

Suggested change
while current.next != None:
current = current.next
current.next = new_node
self.tail = current.next
self.tail.next = new_node

# method that inserts a given value as a new last node in the linked list
# Time Complexity: ?
# Space Complexity: ?
def add_last(self, value):

Choose a reason for hiding this comment

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

👍


# 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 +126 to +133
if current.value == value:
current.next = current.next.next
return
prev = current
current = current.next
if current.value == value:
prev.next = None
self.tail = prev

Choose a reason for hiding this comment

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

We want to stop a node earlier in order to drop the deleted node in one line:

Suggested change
if current.value == value:
current.next = current.next.next
return
prev = current
current = current.next
if current.value == value:
prev.next = None
self.tail = prev
if current.next.value == value:
current.next = current.next.next
current = current.next

@@ -89,7 +152,15 @@ def visit(self):
# Time Complexity: ?
# Space Complexity: ?
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

Comments