Skip to content

Conversation

@ethiapath
Copy link
Owner

No description provided.


7. What is the runtime complexity of your optimized code in `names.py`?

(n log n)^2

Choose a reason for hiding this comment

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

just get rid of the **2 and you've got it :)

duplicates = []
for name_1 in names_1:
if bst.contains(name_1):
if binary_search(names_2, name_1):

Choose a reason for hiding this comment

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

nice going. personally, I like this better than risking having an unbalanced BST.

self.left = None
self.right = None

def depth_first_for_each(self, cb):

Choose a reason for hiding this comment

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

perfect

def breadth_first_for_each(self, cb):
pass
queue = []
queue.insert(0, self)

Choose a reason for hiding this comment

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

aaand nice :) only real change needed

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.

3 participants