Question 136
[Q.36] What is the maximum number of nodes in a binary tree of height 'h' (where height of root node is 0)?
Max nodes in height h tree = 1 + 2 + 4 + ... + 2^$h = 2^{h+1} - 1$.
[Q.36] What is the maximum number of nodes in a binary tree of height 'h' (where height of root node is 0)?
Max nodes in height h tree = 1 + 2 + 4 + ... + 2^$h = 2^{h+1} - 1$.
[Q.37] Which sorting algorithm is stable and has a guaranteed worst-case time complexity of O(n log n)?
Merge sort is stable and runs in O(n log n) time in all cases.
[Q.38] What is the time complexity to insert an element at the beginning of a singly linked list (given head pointer)?
Inserting at head takes constant time O(1).
[Q.39] Floyd-Warshall algorithm is used to solve which problem?
Floyd-Warshall computes shortest paths between all pairs of vertices in O(V^3) time.
[Q.40] What is the tight worst-case time complexity of Breadth-First Search (BFS) on a graph with V vertices and E edges?
BFS visits every vertex and edge once, taking O(V + E) time.