-
Notifications
You must be signed in to change notification settings - Fork 0
hargobind-atwal #2
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
base: master
Are you sure you want to change the base?
Conversation
Data_Structures_Answers.md
Outdated
|
|
||
| 7. What is the runtime complexity of your optimized code in `names.py`? | ||
|
|
||
| (n log n)^2 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
No description provided.