Skip to content

Cedar - Lux Barker#44

Open
k-nox wants to merge 3 commits intoAda-C16:masterfrom
k-nox:master
Open

Cedar - Lux Barker#44
k-nox wants to merge 3 commits intoAda-C16:masterfrom
k-nox:master

Conversation

@k-nox
Copy link

@k-nox k-nox commented Jun 16, 2022

No description provided.

@chimerror
Copy link

Grabbing this to grade!

Copy link

@chimerror chimerror left a comment

Choose a reason for hiding this comment

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

Good work!

I added a comment about your add_helper implementation having a slight performance problem, but everything else looks fine enough for a Green.

curr.left = self.add_helper(curr.left, new_node)
else:
curr.right = self.add_helper(curr.right, new_node)
return curr

Choose a reason for hiding this comment

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

This implementation of add_helper works, but definitely does a bit of extra work in setting nodes. Essentially, every node on the path to where the new node ends up will have either its left or right node "updated", though most of these will be updated to the exact same node. The only one that gets a meaningful update is whenever the bottom of the tree is reached and gets its left/right node updated to the new node. These updates happen in lines 31 and 32.

This probably will not be too bad of a performance hit, but there is a way that you can do this and just update only the node you need.

But this overall fine enough!

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