Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern
What is the minimum possible height of a binary tree with 100 nodes (height of a single node = 0)?
- A. 7
- B. 6
- C. 5
- D. 50
Correct answer: B. 6
A tree of height h holds at most 2^(h + 1) − 1 nodes; h = 5 allows only 63 and h = 6 allows 127 ≥ 100, so the minimum is ⌊log₂ 100⌋ = 6. 7 is the number of levels.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- With the edges sorted first, what is the time complexity of Kruskal's algorithm using a union-find structure, for a graph with V vertices…
- Which single-source shortest path algorithm can detect a negative-weight cycle reachable from the source?
- A topological ordering of a directed graph exists if and only if the graph is:
- A heap is stored in a 0-indexed array. What is the index of the parent of the element at index 10, and of its left child?
- Using the master theorem, what is the solution of T(n) = 2T(n/2) + n?
- In the activity selection problem (choose the most non-overlapping intervals), which greedy rule always gives an optimal answer?