Q5
The worst case running time to search for an element in a balanced binary search tree with elements is
Show answer without attempting
Answer: C
GATE CS · Programming and Data Structures · 2 questions
2 Tree Data Structures questions from GATE CS papers (2012), each with the official answer key. Part of Programming and Data Structures. Answer any question right here and it is marked straight away, or practise them one at a time.
Answer: C
int height (treeptr n)
{ if (n == NULL) return -1;
if (n -> left == NULL)
if (n -> right == NULL) return 0;
else return [B1] ; // Box 1
else { h1 = height (n -> left);
if (n -> right == NULL) return (1+h1);
else { h2 = height (n -> right);
return [B2] ; // Box 2
}
}
}Answer: A
0/20 correct0 marks