Yahoo Interview Question for Software Engineer / Developers






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

For n matches the number of tournaments needs to play is n-1

Ex:
teams-tournaments
2-1
3-2
4-3
5-4
6-5
7-6

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

this questions seems to bear a lot of ambiguity.. plz clear the procedure of promoting the odd i.e 9th team in upper levels.if the promotion is to the level right above it then the answer is 11.
gullu do reply to this post ..

- saumils1987 September 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

8 matches .. as from 9 teams only 1 will win , rest 8 teams must lose , in knockout tournament 1 team goes out in 1 match .

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

When the number of teams is not a square of 2, then we need to have byes for some teams. (this is how tournament brackets are constructed).
A binary tree needs to be built and then the number of non-leaf nodes needs to calculated - that will be the number of matches.
Find x where x is the nearest power of 2 less than n.
n-x teams are extra, choose another (n-x) teams from the pool. Remaining teams = n - 2(n-x) = 2x - n. So, 2(n-x) teams will play in the first round while the remaining get a bye. After round 1, we will get 2*(n-x)/2 + (2x-n) = x number of teams. Since x is a perfect square of 2, we can build the binary tree from up there.
The goal is to get to a square of 2 number of teams after round 1.

Number of matches: (n-x) in the first round + (ln(x) + 1)
(Number of non-leaf nodes in a full binary tree is ln(x) + 1 where x is the number of leaves)

Given this, if n = 9, x = 8. So, number of matches = (9-8) + (ln 8 + 1) = 1 + (3 + 1) = 5.

- Metta October 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Oops, messed up the number of non-leaf nodes formula, sorry.

Number of non-leaf nodes in a perfect binary tree = 2*(Number of leaf nodes) - 1 - (Number of leaf Nodes)

So, here, the answer is (9 - 8) + (2*8) - 1 - 8 = 8.

- Metta October 10, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Number of non-leaf nodes in a perfect binary tree = (Number of leaf nodes) - 1

- djebel February 04, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Since we are interested in the number of losers....the answer should be 8.

- Pedro November 08, 2010 | 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