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

Lilly C16 #50

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

Lilly C16 #50

wants to merge 1 commit into from

Conversation

waterlilly169
Copy link

No description provided.

else:
current = current.right

# Time Complexity: o(1)

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.append({"key":current.key, "value":current.value})
result = self.inorder_helper(current.right, result)
return result

def inorder(self):

Choose a reason for hiding this comment

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

👍

result.append({"key":current.key, "value":current.value})
result = self.preorder_helper(current.left, result)
result = self.preorder_helper(current.right, result)
return result
def preorder(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:
def postorder(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:
def height(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(log(n))
# Space Complexity: O(n)

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)

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):

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