Question: Topics Step 1 :generate 50 random numbers ranging from 1 to 99 and store it in an array (DO NOT SORT THE ARRAY). Print these

Topics

Step 1 :generate 50 random numbers ranging from 1 to 99 and store it in an array (DO NOT SORT THE ARRAY). Print these values to the screen.

Step 2: Now take one number at a time sequentially starting from the leftmost value (the value at index position 0 of the array) and insert it into a Binary Search Tree.

You can use a second array to store the Binary Search Tree - they must use the formula we discussed in class to store Left Child and Right Child.

Step 4: Upon building the Binary Search Tree, they must follow the rule that LeftChild < Parent <= RightChild.

Step 5: Print out the values of this second array.

Note: you must compare the original distribution of the values in the array vs the distribution after creating the Binary Search Tree (the second array/ArrayList) by printing this observation/comparison to the screen.

If a node has no left child or right child or both, the corresponding position of its left child or right child or both should be -1

the data type of each element in the array( used to store the BST) should be int

Index of the array is used to location the child.

Please use array for Binary Tree

Thanks!

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!