Skip to content

Spruce - Angela Fan#71

Open
fan-gela wants to merge 2 commits intoAda-C16:masterfrom
fan-gela:master
Open

Spruce - Angela Fan#71
fan-gela wants to merge 2 commits intoAda-C16:masterfrom
fan-gela:master

Conversation

@fan-gela
Copy link

No description provided.

Copy link

@kyra-patton kyra-patton 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 Angela. I left some comments on time and space complexity, but overall it seems like you have a good understanding of linked lists.

🟢

# Space Complexity: ?
# Time Complexity: O(1)
# Space Complexity: O(1)
def get_first(self):

Choose a reason for hiding this comment

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

# Space Complexity: ?
# 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.

# returns true if found, false otherwise
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(1)

Choose a reason for hiding this comment

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

⏱ Time complexity is O(n) since in the worst case the node with the value you are searching for will be the last node in the list, and you will have to iterate through every node in the list.

# Space Complexity: ?
# Time Complexity: O(1)
# 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.

# Space Complexity: ?
# Time Complexity: O(n)
# 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 245 to 246
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

⏱🪐 Time and space complexity?

Comment on lines 230 to 231
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

⏱🪐 Time and space complexity?

Comment on lines 214 to 215
# Time Complexity: ?
# Space Complexity: ?

Choose a reason for hiding this comment

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

⏱🪐 Time and space complexity?

# returns the value at the middle element in the singly linked list
# Time Complexity: ?
# Space Complexity: ?
def find_middle_value(self):

Choose a reason for hiding this comment

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

# assume indexing starts at 0 while counting to n
# Time Complexity: ?
# Space Complexity: ?
def find_nth_from_end(self, n):

Choose a reason for hiding this comment

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

You could also take advantage of the get_at_index method you wrote

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