Skip to content

Rock - N.Lucuab#63

Open
NLucuab wants to merge 1 commit intoAda-C15:masterfrom
NLucuab:master
Open

Rock - N.Lucuab#63
NLucuab wants to merge 1 commit intoAda-C15:masterfrom
NLucuab:master

Conversation

@NLucuab
Copy link
Copy Markdown

@NLucuab NLucuab commented Jan 26, 2022

Linked List project - passes all 27 required tests

Copy link
Copy Markdown

@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 Nyckolle, you hit the learning goals here. Well done.

Comment on lines +16 to 18
# Time Complexity: O(1)
# Space Complexity: O(1) - nothing new is being added, so memory is unaffected
def get_first(self):
Copy link
Copy Markdown

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)? Only 1 node is being added, so 0(1) sounds right memory-wise
def add_first(self, value):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +35 to 37
# Time Complexity: O(n) - traverses the whole list
# Space Complexity: O(1) - nothing new is being added, so memory is unaffected
def search(self, value):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +47 to 49
# Time Complexity: O(n) - traverses the list
# Space Complexity: O(1) - no new node is being added, so memory is unaffected
def length(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +64 to 66
# Time Complexity: O(n) - traverses the list to find value
# Space Complexity: O(1) - no new node is being added, so memory is unaffected
def get_at_index(self, index):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +98 to 100
# Time Complexity: O(1) - only inserts 1 value
# Space Complexity: O(n) - traverses the list in order to find the end, and then adds on value
def add_last(self, value):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 The time complexity is O(n) because you traverse to the end of the list. The space complexity is O(1) because you only ever add one node.


# method to return the max value in the linked list
# returns the data value and not the node
def find_max(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +133 to 135
# Time Complexity: O(n) - traverses list to find specified value
# Space Complexity: O(1) - deletes only 1 value
def delete(self, value):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +165 to +166
# Time Complexity: O(n) - traverses list
# Space Complexity: O(n) - prints out every value
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +179 to 181
# Time Complexity: O(n) - traverses/reverses entire list
# Space Complexity: O(1) - no new nodes are being added
def reverse(self):
Copy link
Copy Markdown

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