Exercise 2 Write an efficient program that allows a user to input a set of integers (the input size should be defined by
Posted: Fri May 20, 2022 11:40 am
Exercise 2 Write an efficient program that allows a user to input a set of integers (the input size should be defined by the user). The program should create a binary tree and find the inorder predecessor of a given key in it. If the key does not lie in the BST, return the previous greater node (if any) present in the BST. An inorder predecessor of a node in the BST is the previous node in the inorder traversal of it. For example, consider the following tree: 15 10 20 12 16 25 The inorder predecessor of 8 does not exist. The inorder predecessor of 10 is 8 The inorder predecessor of 12 is 10 The inorder predecessor of 20 is 16