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

Diana - Pine #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Diana - Pine #74

wants to merge 1 commit into from

Conversation

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

✨ Really nice work, Diana. Since you chose to do a doubly linked lists, I left a few comments about refactoring some of your methods for doubly linked lists. Let me know what questions you have.

🟢

self.value = value
self.next = next_node
self.previous = prev_node #This line because this is a doubly linked list

Choose a reason for hiding this comment

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

😎 Ooh doubly linked list

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

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

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

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

while current_node.next:
current_node = current_node.next
current_node.next = new_node


# method to return the max value in the linked list
# returns the data value and not the node
def find_max(self):

Choose a reason for hiding this comment

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

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n)
# Space Complexity: O(n)
def delete(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 +143 to +144
if new.value == value:
break

Choose a reason for hiding this comment

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

We generally try and avoid using break statements unless really necessary. Might you be able to refactor your code to eliminate this?

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(n)
# Space Complexity: O(1)

Choose a reason for hiding this comment

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

🪐 Space complexity will be O(n) here because the function creates a helper_list which will end up holding all the nodes in the linked list

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

Choose a reason for hiding this comment

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

Since you have a doubly linked list you also need to think about how you redirect your previous and tail pointers.

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