Question: WRITE IN C++ : Enter integers through the keyboard. While entering the numbers, create a binary search tree. For a NULL node enter -1. For

WRITE IN C++ :

Enter integers through the keyboard. While entering the numbers, create a binary search tree. For a NULL node enter -1. For the created binary tree write its preorder, inorder, postorder and level order traversals. Then, ask the user to insert a value of a node in the tree. Write a function to find the predecessor of the given node (its value and address). If the node is not found, the function should return NULL. If the found node is the root, the function should return NULL, as well. If the first value that is entered is equal to -1, then don't print the tree, its traversals or the predecessor of the given node, but instead only print a message that the tree is empty.

Example output

:WRITE IN C++ : Enter integers through the keyboard. While entering the

Enter the walue for the root (1 for empty tree): 5 Enter the next element to enter in the binary search tree (1 for end): 2 Enter the next element to enter in the binary search tree (1 for end =1 Enter the next element to enter in the binary search tree (1 for end =3 Enter the next element to enter in the binary search tree (1 for end )8 Enter the next element to enter in the binary search tree (1 for end =6 Enter the next element to enter in the binary search tree (1 for end =7 Enter the next element to enter in the binary search tree (1 for end )9 Enter the next element to enter in the binary search tree (1 for end =1 5(0782950) 12 (0)782968) 11 (0) 1782980) INULI INULL 13(0782998) INULL I INULL 18(07829b0) 16(0782co) I INULL I I7 (0x7829e0) INULL I I INULL i iNULL I INULL Enter the element whose predecessor has to be found: 3 The predecessor of the element 3 is the element 2 located on address 0782968 Process returned 0 (0x) execution time =15.644s Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!