Skip to content

Maple: Sabrina Lauredan#76

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

Maple: Sabrina Lauredan#76
SabrinaLauredan wants to merge 1 commit intoAda-C16:masterfrom
SabrinaLauredan:master

Conversation

@SabrinaLauredan
Copy link
Copy Markdown

No description provided.

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.

✨ Hi Sabrina, I have some concerns about your implementation and you missed implementing the last required function reverse. Take a look at my comments and let me know what questions you have.

🟡

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

# Space Complexity: ?
# Time Complexity: O(1)
# Space Complexity: O(1)
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: O(n)
# Space Complexity: O(1)
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: O(n)
# Space Complexity: O(1)
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: O(n)
# Space Complexity: 0(1)
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 +118 to +123
index = 0
current = self.head
prev = self.head
temp = self.head
while current is not None:
if index == 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.

Same thing here you are checking to see if the node's value attribute is equal to the passed in value, not to see whether value equals the index of the node.

while current is not None:
if index == value:
temp = current.next
break
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤓 We generally like to avoid break statements where possible. How might you refactor your code to eliminate this break statement?

current = current.next
index += 1
prev.next = temp
return prev
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's not necessary to return anything for this function

Suggested change
return prev

Comment on lines +133 to +134
# Time Complexity: O(n)
# Space Complexity: O(n)
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 -89 to -92
# Time Complexity: ?
# Space Complexity: ?
def reverse(self):
pass
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ This is a required function

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