Skip to content

Lilly C16 #50

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

Lilly C16 #50
waterlilly169 wants to merge 1 commit intoAda-C16:masterfrom
waterlilly169:master

Conversation

@waterlilly169
Copy link
Copy Markdown

No description provided.

else:
current = current.right

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

Time complexity for find will be O(log n) because you are still iterating through the BST, but only one half of it every time.

result = self.inorder_helper(current.right, result)
return result

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

👍

result = self.preorder_helper(current.left, result)
result = self.preorder_helper(current.right, result)
return result
def preorder(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.

👍


# Time Complexity:
# Space Complexity:
def postorder(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.

👍


# Time Complexity:
# Space Complexity:
def height(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.

👍

# Time Complexity:
# Space Complexity:
# Time Complexity: O(log(n))
# Space Complexity: O(n)
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 aren't recursively calling this, the space complexity is O(1) because no new memory is dependent upon the size of the input

current = current.right

# Time Complexity: o(1)
# Space Complexity: O(n)
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 aren't recursively calling this, the space complexity is O(1) because no new memory is dependent upon the size of the input

# Time Complexity: o(1)
# Space Complexity: O(n)
# search for a node in the tree
def find(self, key):
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