InterviewSolution
Saved Bookmarks
| 1. |
Consider the same code as given in above question. What does the function print() do in general?The function print() receives root of a Binary Search Tree (BST) and a positive integer k as arguments.// A BST nodestruct node {int data;struct node *left, *right;};int count = 0;void print(struct node *root, int k){if (root != NULL && count <= k){print(root->right, k);count++;if (count == k)printf("%d ", root->data);print(root->left, k);}}(A) Prints the kth smallest element in BST(B) Prints the kth largest element in BST(C) Prints the leftmost node at level k from root(D) Prints the rightmost node at level k from root |
| Answer» | |