Skip to content

Maple - Rhyannon Rodriguez#72

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

Maple - Rhyannon Rodriguez#72
rhyannonjoy wants to merge 1 commit intoAda-C16:masterfrom
rhyannonjoy:master

Conversation

@rhyannonjoy
Copy link
Copy Markdown

Only required exercises completed

Copy link
Copy Markdown

@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 Rhyannon! I left one comment about the time complexity of get_first. Let me know what questions you have.

🟢

# returns None if the list is empty
# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: Linear O(N), size of LL
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱ Time complexity would actually be O(1) here, because you only ever need to look at the head of the list.

# Space Complexity: ?
# Time Complexity: Adding a head, Constant O(1)
# Space Complexity: Constant O(1) not creating new data structure
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.

# Space Complexity: ?
# Time Complexity: Linear O(N), size of the LL
# Space Complexity: Constant O(1), we're not creating data structures
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.

# Space Complexity: ?
# Time Complexity: Linear O(N), size of the LL
# Space Complexity: Constant O(1), we're not creating data structures
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.

# Space Complexity: ?
# Time Complexity: Linear O(N), size of the LL
# Space Complexity: Constant O(1), we're not creating data structures
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.


# 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.

# Space Complexity: ?
# Time Complexity: Linear O(N), size of the LL
# Space Complexity: Constant O(1), we're not creating data structures
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.

# Space Complexity: ?
# Time Complexity: Linear O(N), size of the LL
# Space Complexity: Linear O(N), depending on the size of the visited_list
def visit(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.

visited_list = []
current = self.head

while current:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

# Space Complexity: ?
# Time Complexity: Linear O(N), depending on the size of the LL
# Space Complexity: Constant O(1), no creation of new data structures
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