Skip to content

Linked List CS Fun Project#65

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

Linked List CS Fun Project#65
ASY13 wants to merge 1 commit intoAda-C16:masterfrom
ASY13:master

Conversation

@ASY13
Copy link

@ASY13 ASY13 commented Jul 13, 2022

No description provided.

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: 0(1)
# Space Complexity: 0(n)

Choose a reason for hiding this comment

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

This should be O(1), because we aren't creating any new data inside the function that is dependent on the size of the link

# Space Complexity: ?
# Time Complexity: 0(1)
# Space Complexity: 0(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 29 to 30
# 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?

# insert the new node at the beginning of the linked list
# Time Complexity: ?
# Space Complexity: ?
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 42 to 43
# 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 139 to 140
# 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?

# method to delete the first node found with specified value
# Time Complexity: ?
# Space Complexity: ?
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 170 to 171
# 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 +181 to +186
if not reversed_link:
next_node = current.next
current.next = None
reversed_link = current
current = next_node
else:

Choose a reason for hiding this comment

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

hmm I don't think we need this first if statement if we change the while loop to while current != None. I think starting reversed_link as None like you did and then going into the else statement will work

Comment on lines +191 to +192
current.next = reversed_link
reversed_link = current

Choose a reason for hiding this comment

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

we can get rid of these two lines if we change the while loop

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