(a) Insert the following keys one by one into a binary search tree in the…

PYQ GATE 2001Modified — slightly modified from the official paper; see the solution

(a) Insert the following keys one by one into a binary search tree in the order specified. 15, 32, 20, 9, 3, 25, 12, 1 Show the final binary search tree after the insertions.

(b) Draw the binary search tree after deleting 15 from it.

(c) Complete the statements S1, S2 and S3 in the following function so that the function computes the depth of a binary rooted at t.

typedef struct tnode {
  int key;
  struct tnode *left, *right;
} *Tree;
int depth(Tree t)
{
  int x, y;
  if (t == NULL) return 0;
  x = depth(t->left);
  S1: ____________;
  S2: if (x > y) return ____________;
  S3: else return ____________;
}

Attempted by 1 students.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…