GATE CS 2004 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0231

A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is
  1. A
    \(\Theta (n)\)
  2. B
    \(\Theta (nlog n)\)
  3. C
    \(\Theta (n^{2})\)
  4. D
    \(\Theta (n^{2}log n)\)

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option B.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/1079/gate2004-85

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com