Write a program in C/C++ to that receives N number of integer values from a user, stores the inputted values in a binary search tree, and performs some basic operations on the tree. The program displays the elements of the binary search tree in in-order traversal. The program then prompts the user to provide an integer number (target value) to search in the tree. If the target value does not appear in the tree, the program inserts the value in an appropriate place according to the property of node insertion of binary search tree. If the target value appears in the tree, the program deletes the target value from the tree and preserves the property of binary search tree. In both cases, the program displays the modified binary search tree in in- order traversal. Your output format should be as shown in the test runs. Your program must contain the following user-defined functions: -  insertNode – this function inserts the user’s input and creates a binary search tree. -  inOrder – this function displays the entire tree in in-order traversal. -  searchElement – this function receives the target value to search in the tree. -  deleteNode – this function removes the target element from the tree. This function will only be executed if the target element appears in the tree. Example test runs Test Run 1: Enter the number of elements: 5 Enter 5 numbers: 30 50 40 10 20 Tree elements: 10 20 30 40 50 Enter the target number to search: 100 The target element 100 is not in the tree Inserting 100 in the tree Updated tree: 10 20 30 40 50 100 Test Run 2: Enter the number of elements: 7 Enter 7 numbers: 89 45 -1 40 8 7 50 Tree elements: -1 7 8 40 45 50 89 Enter the target number to search: -1 The target element -1 is in the tree. Deleting -1 from the tree. Updated tree: 7 8 40 45 50 89

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 21SA
icon
Related questions
Question
100%

Write a program in C/C++ to that receives N number of integer values from a user, stores the inputted values in a binary search tree, and performs some basic operations on the tree. The program displays the elements of the binary search tree in in-order traversal. The program then prompts the user to provide an integer number (target value) to search in the tree. If the target value does not appear in the tree, the program inserts the value in an appropriate place according to the property of node insertion of binary search tree. If the target value appears in the tree, the program deletes the target value from the tree and preserves the property of binary search tree. In both cases, the program displays the modified binary search tree in in- order traversal.

Your output format should be as shown in the test runs.

Your program must contain the following user-defined functions:

-  insertNode – this function inserts the user’s input and creates a binary search tree.

-  inOrder – this function displays the entire tree in in-order traversal.

-  searchElement – this function receives the target value to search in the tree.

-  deleteNode – this function removes the target element from the tree. This function will only be executed if the target element appears in the tree.

Example test runs

Test Run 1:

Enter the number of elements: 5
Enter 5 numbers: 30 50 40 10 20
Tree elements: 10 20 30 40 50
Enter the target number to search: 100 The target element 100 is not in the tree Inserting 100 in the tree

Updated tree: 10 20 30 40 50 100

Test Run 2:

Enter the number of elements: 7

Enter 7 numbers: 89 45 -1 40 8 7 50

Tree elements: -1 7 8 40 45 50 89

Enter the target number to search: -1

The target element -1 is in the tree.

Deleting -1 from the tree.

Updated tree: 7 8 40 45 50 89

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning