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

C15 - Christian - linked-list #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Crintion
Copy link

@Crintion Crintion commented Oct 2, 2021

No description provided.

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.

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

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

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

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

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

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

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)

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

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

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)


print(", ".join(helper_list))
# print(", ".join(helper_list))

# method to reverse the singly linked list
# note: the nodes should be moved and not just the values in the nodes
# Time Complexity: ?
# Space Complexity: ?
def reverse(self):

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