Skip to content

C15 - Christian - linked-list#40

Open
Crintion wants to merge 2 commits intoAda-C15:masterfrom
Crintion:master
Open

C15 - Christian - linked-list#40
Crintion wants to merge 2 commits intoAda-C15:masterfrom
Crintion:master

Conversation

@Crintion
Copy link
Copy Markdown

@Crintion Crintion commented Oct 2, 2021

No description provided.

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.

Overall not bad Christian, I left some notes but you hit most of the learning goals here. Take a look at my comments and let me know what questions you have.

Comment on lines 16 to 18
# Time Complexity: ?
# Space Complexity: ?
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.

👍 Time/space complexity

Comment on lines +27 to 29
# Time Complexity:O(1)
# Space Complexity: O(n)
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 is O(1) because you're not creating a bunch of nodes (always just one).

Comment on lines +35 to 37
# Time Complexity: O(n)
# Space Complexity: 0
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 46 to 49
# method that returns the length of the singly linked list
# Time Complexity: ?
# Space Complexity: ?
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.

👍 time/space complexity?

Comment on lines 60 to 62
# Time Complexity: ?
# Space Complexity: ?
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.

👍 time/space complexity?

Good use of the length() method

Comment on lines 118 to 120
# Time Complexity: ?
# Space Complexity: ?
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.

👍 time/space complexity?

while current_node != None:
if current_node.next:
if current_node.next.value == value:
print(current_node.value, current_node.next.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.

You can delete the print stmts

Suggested change
print(current_node.value, current_node.next.value)

current_node.next = current_node.next.next
return
current_node = current_node.next
print(current_node.value, current_node.next.value, "last")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
print(current_node.value, current_node.next.value, "last")

def visit(self):
helper_list = []
current = self.head
# 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.

For visit you can:

  1. Create an empty list
  2. Traverse the linked list like you did previously and at each iteration you can append the current value to the list
  3. You can then return ", ".join(the_list)

# note: the nodes should be moved and not just the values in the nodes
# Time Complexity: ?
# Space Complexity: ?
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.

Just noting this isn't done.

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