Skip to content

Makhabat - Cedar#62

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

Makhabat - Cedar#62
makhabatmaksatbekova wants to merge 1 commit intoAda-C16:masterfrom
makhabatmaksatbekova:master

Conversation

@makhabatmaksatbekova
Copy link
Copy Markdown

No description provided.

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

👍

if self.head == None:
return False
current = self.head
while current != 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.

we can shorten this to:

Suggested change
while current != None:
while current:

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

👍

pass
lenght = 0
current = self.head
while current != 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.

Suggested change
while current != None:
while current:

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

def add_last(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 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.

👍

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

👍

Comment on lines 146 to 147
# Time Complexity: ?
# Space Complexity: ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What do you think the space and time complexity of this is? Is the time complexity dependent on the length of the linked list? Is there any new variables being created that grow larger depending upon the input?


# Defines a node in the singly linked list
class Node:
from platform import node
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

where is this coming from? You've created your own Node class on line 6, so you don't need to import a third-party class

Suggested change
from platform import node

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