Find the Nth largest node in a BST.
Example BST:
Code input/output:
inorder:
1 3 4 6 7 8 10 13 14
Size of BST: 9
1 largest node: 1
2 largest node: 3
3 largest node: 4
4 largest node: 6
5 largest node: 7
6 largest node: 8
7 largest node: 10
8 largest node: 13
9 largest node: 14
Example BST:
Code input/output:
inorder:
1 3 4 6 7 8 10 13 14
Size of BST: 9
1 largest node: 1
2 largest node: 3
3 largest node: 4
4 largest node: 6
5 largest node: 7
6 largest node: 8
7 largest node: 10
8 largest node: 13
9 largest node: 14
Hi.
ReplyDeleteThe output doesn't make sense to me. the 1th largest element in your example should be 14 because its the largest element. second largest should be 13 and so on. Can you please explain.
Thanks