Data Structures | Binary Search Trees | Question 12
Consider the following code snippet in C. The function print() receives root of a Binary Search Tree (BST) and a positive integer k as arguments.
node *left, *right;
count = 0;
(root != NULL && count <= k)
(count == k)
What is the output of print(root, 3) where root represent root of the following BST.
/ \ / \
8 12 16 25
(D) 20 10
Explanation: The code mainly finds out k’th largest element in BST, see K’th Largest Element in BST for details.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.