ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
   
 
Categories  >>  Software  >>  Operating Systems  >>  Data Structures
 
 


 

 
 Windows interview questions  Windows Interview Questions
 Linux interview questions  Linux Interview Questions
 Unix interview questions  Unix Interview Questions
 Solaris interview questions  Solaris Interview Questions
 RTOS interview questions  RTOS Interview Questions
 Bulnex interview questions  Bulnex Interview Questions
 Operating Systems General Concepts interview questions  Operating Systems General Concepts Interview Questions
 Data Structures interview questions  Data Structures Interview Questions
 Operating Systems AllOther interview questions  Operating Systems AllOther Interview Questions
Question
What is the maximum total number of nodes in a tree that has
N levels? Note that the root is level (zero)
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 1
(n)2-1 
Is This Answer Correct ?    11 Yes 34 No
Srikanth
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 2
2^(N+1)-1..

if N=0; it is 2-1=1,1 is the max no of node in the tree
if N=1; it is 4-1=3, 3 is the max no of nodes in the tree
if N=2; it is 8-1=7, 7 is the max

and it goes like that...........
 
Is This Answer Correct ?    94 Yes 5 No
Salmiya Thilsath.a
 
 
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 3
2powN-1 
Is This Answer Correct ?    9 Yes 19 No
Pavan
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 4
(2 pow n)-1,if root level is one and (2 pow n+1)-1, if root
level is zero.
 
Is This Answer Correct ?    21 Yes 9 No
Asharani K P
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 5
(2^(N+1))-1
Suppose level is 2 then total number of nodes will be
1 root
2 left of root and right of root
2 left and right of left of root
2 left and right of right of root
so total nodes are 1+2+2+2=7

by formula (2^(2+1))-1
8-1=7
 
Is This Answer Correct ?    20 Yes 8 No
Gaurav Gupta
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 6
2^(N+1)-1 
Is This Answer Correct ?    16 Yes 6 No
Deba
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 7
if the tree is binary tree [i.e two children max]then
2pow(N) is the answer
if it has 3 max children then
3pow(N)
...............................
if it has n max children then
npow(N)
 
Is This Answer Correct ?    4 Yes 7 No
M.eshwar
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 8
2^N-1 
Is This Answer Correct ?    2 Yes 14 No
Prachi
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 9
to be more generic this kind of problem is best solved
recursivly.

To point out that 2 ^ N AND 3 ^ N are both wrong,
here's a few examples: (the exponet is the amount of levels)
2^0 = 1, correct
2^1 = 2, incorrect, should be 3
2^2 = 4, incorrect, should be 7

And a tree with three children
3^0 = 1, correct
3^1 = 3, incorrect, should be 4
3^2 = 9, incorrect, should be 13

Looking at that I'm sure you can see the pattern.
Let
C = "Number of Possible Children"
N = Levels

N
Σ C^N
j=0

or in C++ code
int NodeCount(int C, int N)
{
if (N < 0) return 0
return NodeCount(C, N-1) + C^N
}
 
Is This Answer Correct ?    7 Yes 4 No
Hex
 
  Re: What is the maximum total number of nodes in a tree that has N levels? Note that the root is level (zero)
Answer
# 10
2^N -1 
Is This Answer Correct ?    12 Yes 6 No
Gopala Krishnan
 

 
 
 
Other Data Structures Interview Questions
 
  Question Asked @ Answers
 
how a polynomial such as 6x^6+4x^3-2x+10 can be represnted by linked list?write an algorithm that reads such an polynomial  1
Stack can be described as a pointer. Explain. Wipro4
what is mean by d-queue?  10
Parenthesis are never needed in prefix or postfix expressions. Why? Microsoft11
why do tree always takes o(log n) time? TCS1
create an singly linked lists and reverse the lists by interchanging the links and not the data? Microsoft13
Write a Binary Search program Microsoft7
simple algorithm for bubble sort?  1
How will inorder, preorder and postorder traversals print the elements of a tree?  11
When will you sort an array of pointers to list elements, rather than sorting the elements themselves?  5
In which data structure, elements can be added or removed at either end, but not in the middle? Wipro41
Tell me real world example of polymorphism and encapsulation . CybAge7
 
For more Data Structures Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com