Skip to content
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

Rock - N.Lucuab #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Rock - N.Lucuab #63

wants to merge 1 commit into from

Conversation

NLucuab
Copy link

@NLucuab NLucuab commented Jan 26, 2022

Linked List project - passes all 27 required tests

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

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

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

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

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

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

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.

while current.next != None:
current = current.next
# set current.next to the new_node
current.next = new_node

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

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

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

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