Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need this written in C++ Enter integers through the keyboard. While entering the numbers, create a binary search tree. For a NULL node enter

I need this written 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, add a function to find the node with the greatest value in the tree (its value and address). If the first value that is entered is equal to -1, then don't print the tree, its traversals or the node with the greatest value, but instead only print a message that the tree is empty.

Example output:

image text in transcribed

Enter the ualue for the root (-1 for empty trees: 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 ) : 6 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 =3 Enter the next element to enter in the binary search tree (1 for end = ? Enter the next element to enter in the binary search tree (1 for end )4 Enter the next element to enter in the binary search tree (1 for end )1 5 (0xc02950) 12 (0xc02968) I 11 (0xc02980) INULL iNULL 13(0xc029c8) INULI 14 (0)xc029f8) iNULL i i IVULL I6 (0xc02998) i iNULL I 18(0xc029b0) i i7 (0xc029e0) I INULL i i NULL I I HULL Leve 1 order: 5 2 6 i 3 s 4 ? The maximum elenent of the tree is 8 at address 0xc029b0. Process returned 0 (0x0) execution time =15.624s Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions