ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   To Refer this Site to Your Friends   Click Here
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 ?    1 Yes 1 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 ?    10 Yes 0 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 ?    0 Yes 2 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 ?    2 Yes 2 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 ?    3 Yes 0 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 ?    1 Yes 1 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 ?    1 Yes 1 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 ?    1 Yes 2 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 ?    1 Yes 0 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 ?    1 Yes 0 No
Gopala Krishnan
 

 
 
 
Other Data Structures Interview Questions
 
  Question Asked @ Answers
 
Parenthesis are never needed in prefix or postfix expressions. Why?  6
What does abstract data type means? TCS6
What do you mean by: Syntax Error, Logical Error, Runtime Error?  2
Explain about the types of linked lists  4
How is it possible to insert different type of elements in stack?  5
The element being searched for is not found in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine that the element is not there, if the elements are completely unordered? Morgan-Stanley7
What is the average number of comparisons in a sequential search?  2
How many different binary trees and binary search trees can be made from three nodes that contain the key values 1, 2 & 3? iGate9
What do you mean by Base case, Recursive case, Binding Time, Run-Time Stack and Tail Recursion? TCS1
Which sort show the best average behavior?  6
What are the parts of root node? BMC2
What is binary tree? BMC5
What is B+ tree? BMC3
What is a data structure? Keane-India-Ltd3
Which one is faster? A binary search of an orderd set of elements in an array or a sequential search of the elements. Syntel9
Explain binary searching, Fibinocci search. IBM1
How will inorder, preorder and postorder traversals print the elements of a tree?  6
In which data structure, elements can be added or removed at either end, but not in the middle? Wipro19
How would you sort a linked list?  3
When will you sort an array of pointers to list elements, rather than sorting the elements themselves?  2
 
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 © 2007  ALLInterview.com.  All Rights Reserved.

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