Bloomberg LP Interview Question for Software Engineer / Developers






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

maximum number of leaf nodes would be 2^10.

- recentKid February 26, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the maximum number of leaf nodes should be 2^9

- jack March 21, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2^10 - 1

- vodangkhoa March 21, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

number of nodes will not odd for sure except for root level which has 1 node. Number of nodes depends upon whether u consider root as level 1 or level 0. If root is level 0 then level at depth 10 will have 2^10 nodes otherwise 2^9

- sp101 September 05, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A balanced binary tree is where the depth of all the leaves differs by at most 1. Balanced trees have a predictable depth (how many nodes are traversed from the root to a leaf, root counting as node 0 and subsequent as 1, 2, ..., depth). This depth is equal to the integer part of log2(n) where n is the number of nodes on the balanced tree. Example 1: balanced tree with 1 node, log2(1) = 0 (depth = 0). Example 2: balanced tree with 3 nodes, log2(3) = 1.59 (depth=1). Example 3: balanced tree with 5 nodes, log2(5) = 2.32 (depth of tree is 2 nodes).

so log2(number of nodes)= depth
so number of Nodes = 2 power 10

i copied from wiki
http://en.wikipedia.org/wiki/Binary_tree

- Anonymous July 24, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void FindNodeInDepth(node* root, int currentLayer, int targetLayer, int& count)
{
if (currentLayer == targetLayer)
{
++count;
}
else
{
if (root->left)
FindNodeInDepth(root->left, currentLayer+1, targetLayer, count);
if (root->right)
FindNodeInDepth(root->right, currentLayer+1, targetLayer, count);
}
}

- sunbow.xs@hotmail.com October 18, 2008 | 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