Question 86
Which data structure is inherently used when executing a recursive function?
Function calls push stack frames containing parameters, local variables, and return addresses onto the system call stack.
Which data structure is inherently used when executing a recursive function?
Function calls push stack frames containing parameters, local variables, and return addresses onto the system call stack.
What is the time complexity of topological sort on a DAG with V vertices and E edges using Kahn's algorithm (In-Degree Queue)?
Kahn's algorithm processes each vertex once when its in-degree becomes 0 and decrements edge counts, taking O(V + E) total time.
In dynamic programming, storing results of subproblems in a lookup table during recursive calls is known as:
Memoization caches recursive subproblem results in a array/hash table to avoid redundant computation.
What is the minimum possible height of a binary tree with 7 nodes, when the root is at height 0?
To minimize height, the tree should be as full as possible. A binary tree of height 2 can contain up to $2^{2+1} - 1$ = 7 nodes, so the minimum possible height is 2.
Which data structure is best suited for evaluating postfix expressions?
A Stack is used for postfix evaluation: operands are pushed onto the stack, and when an operator is encountered, top two operands are popped, evaluated, and the result is pushed back.