Bloomberg LP Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

in average case, it is O(log n), but the worst case , it is O(n)

- shoushou December 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Only if the tree isn't balanced! If it's balanced then even worst case is O(log n).

- Anonymous January 18, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

log(n)

- Anonymous October 18, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 0 votes

actually o(tree height)

- acoader November 03, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Since it is a binary tree, won't the tree height be log(n)

- Jit December 02, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Tree construction:
Worst: O(n^2)
Best: O(n log n)

Look-up
O(Height_Of_the_Tree)

- Anonymous August 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from: <introduction of algorithm>
it's O(height)
insert, delete, find, previous, succ,
for balanced tree, like red-black tree, O(logN)
for un-balanced tree, O(n)

- Anonymous September 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For unbalanced BSTs:
--------------------
Insertion - O(log n) for average time, O(n) for worst time
Deletion - O(log n) for average time, O(n) for worst time
Search / Lookup - O(log n) for average time, O(n) for worst time
PreOrder - O(n)
PostOrder - O(n)
InOrder - O(n)
BFS - O(n)
DFS - O(n)

For balanced BSTs:
--------------------
Insertion - O(log n) most of the time
Deletion - O(log n) most of the time
Search / Lookup - O(log n) most of the time
PreOrder - O(n)
PostOrder - O(n)
InOrder - O(n)
BFS - O(n)
DFS - O(n)

For skewed(degenerate or BSTs like linked lists) BSTs:
------------------------------------------------------
Insertion - O(n) always
Deletion - O(n) always
Search / Lookup - O(n) always
PreOrder - O(n)
PostOrder - O(n)
InOrder - O(n)
BFS - O(n)
DFS - O(n)

- Helper December 15, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More