Skip to content

Pine- Alma #54

Open
abecerrilsalas wants to merge 2 commits intoAda-C16:masterfrom
abecerrilsalas:master
Open

Pine- Alma #54
abecerrilsalas wants to merge 2 commits intoAda-C16:masterfrom
abecerrilsalas:master

Conversation

@abecerrilsalas
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, Alma. I left a few comments on time and space complexity. Let me know what questions you have.

🟢

class LinkedList:
def __init__(self):
self.head = None # keep the head private. Not accessible outside this class
self.head = None # keep the head private. Not accessible outside this class
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

😎 Doubly linked list! Very nice!

# 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(n)
# 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.

if temp is None:
return
prev.next = temp.next
temp = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can probably remove this

Suggested change
temp = None

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

✨ However you're only looping through the length of the list once, so time complexity would be O(n)

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

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

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