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

Brittany- Binary Search Tree #59

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

Conversation

brittanygcle
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Nice work Brittany, you hit all the learning goals here. Well done.

if val == None:
val = key

self.key = key
self.value = val
self.left = None
self.right = None


def add(self, key, value=None):

Choose a reason for hiding this comment

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

👍 Nice recursive solution

return self.right
return self.right.add(key, value)

def inorder(self, list):

Choose a reason for hiding this comment

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

👍

if self.right is not None:
self.right.inorder(list)

def preorder(self, list):

Choose a reason for hiding this comment

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

👍

if self.right is not None:
self.right.preorder(list)

def postorder(self, list):

Choose a reason for hiding this comment

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

👍

"value": self.value
})

def height(self):

Choose a reason for hiding this comment

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

👍

Comment on lines +77 to +79
# Time Complexity:
# Space Complexity:
def add(self, key, value=None):

Choose a reason for hiding this comment

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

👍 Time/space Complexity?

Comment on lines +101 to 103
# Time Complexity: o(1)
# Space Complexity: o(1)
def inorder(self):

Choose a reason for hiding this comment

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

👍 Time/space Complexity are both O(n)

Comment on lines +109 to 112
# Time Complexity: o(n)
# Space Complexity:0(n)

# Time Complexity:
# Space Complexity:
def preorder(self):

Choose a reason for hiding this comment

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

👍 Time/space Complexity are both O(n)

Comment on lines +118 to 120
# Time Complexity: 0(log n)
# Space Complexity:o(1)
def postorder(self):

Choose a reason for hiding this comment

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

👍 Time/space Complexity are both O(n)

Comment on lines +126 to 128
# Time Complexity: o(n)
# Space Complexity:0(n)
def height(self):

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