Skip to content

Diana - Pine#74

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

Diana - Pine#74
DLozanoC wants to merge 1 commit intoAda-C16:masterfrom
DLozanoC:master

Conversation

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

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

🟢

def __init__(self, value, next_node = None, prev_node = None):
self.value = value
self.next = next_node
self.previous = prev_node #This line because this is a doubly linked list
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

😎 Ooh doubly linked list

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


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

Comment on lines +143 to +144
if new.value == value:
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 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)
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 will be O(n) here because the function creates a helper_list which will end up holding all the nodes in the linked list

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

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