Question: Java Program : You are to write a program name BSTree.java that will: Generate 100 random integer numbers ranging from 1 99. Store these numbers

Java Program :

You are to write a program name BSTree.java that will:

Generate 100 random integer numbers ranging from 1 99.

Store these numbers in a data structure of your choice and display the data on the screen. DO NOT SORT THIS DATA STRUCTURE.

Now build a Binary Search Tree using this set of numbers. You MUST insert the values into the tree starting from the first element of your Data Structure and go sequentially.

After building the tree, use an infix recursive method to display the data on the screen.

To build the Binary Search Tree, you must create your own Linked List.

Can you please tell me correct my code to where it runs?

package bstree;

/** * * @author hgnel */ public class Node { int data ; Node left; Node right; public Node (int input) { this.data = input; } public void setleft(Node input){ left = input; } public void setright(Node input){ right = input; } }

package bstree;

import java.util.ArrayList; import java.util.LinkedList; import java.util.Random; import static jdk.nashorn.tools.ShellFunctions.input; public class BSTree {

public static void main(String[] args) { ArrayList Array = new ArrayList(); LinkedList List= new LinkedList(); Random list = new Random(); System.out.println("random numbers generated"); System.out.println(""); // for loop to generate random numbers for (int i = 0; i < 100; i++ ) { Array.add(list.nextInt(99)); System.out.println(Array.get(i)); } Node tree = new Node(); { } // this is the for loop that adds to the link list //] for (int value : Array) { } public Node leave (Node input, int value, null) { if ( input.data <= value ) { input.data = value(input.left,); } if (input.data >= value ) { } } if(input.data == null) { return null; }

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!