Computer Science EngineeringHard
A binary tree with n nodes stored with left and right pointers has how many NULL pointers in total?
- A. n - 1
- B. n
- C. 2n
- D. n + 1
Correct answer: D. n + 1
There are 2n pointer fields and n-1 of them are used by edges, leaving 2n-(n-1) = n+1 NULL pointers.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- How many times does c++ execute in: int c=0; for(int i=1;i<=100;i=3) c++;
- The height (in edges) of a binary heap that stores 1000 elements is
- For void f(int n){ if(n>0){ f(n-1); printf("%d ",n); f(n-1); } }, how many numbers are printed by the call f(4)?
- The array [4, 10, 3, 5, 1] is converted into a max-heap by the standard bottom-up build-heap procedure. The resulting array is
- A binary tree has exactly 15 nodes with two children. How many leaves does it have?
- The auxiliary space used by a recursive DFS on a graph with V vertices, in the worst case, is