Using a Binary Search Tree
Using the LinkedBinarySearchTree class in the jss2 for chapters 12 and 13, write a program that exercises all of the operations except:
removAllOccurrences
findAgain
replacement
Details
Your program will read instruction from the file: numbers.txt
The file is formatted as follows:
The first line in the file will contain a list of numbers used to create a binary tree on one line.
Each ensuing line will contain one of the following list of commands that correspond to the BST methods
ADD someNumber// Add the number to the BST
REMOVE someNumber// Remove the number from the BST
REMOVEMAX// Remove the largest number
REMOVEMIN// Remove the smallest number
FINDMAX// Find and print the largest number
FINDMIN// Find and print the smallest number
FIND someNumber// Find and print a particular number
PREORDER// Print the tree using preorder traversal. You write this.
POSTORDER// Print the tree using postorder traversal. You write this.
INORDER// Print the tree using inorder traversal. You write this.
Miscellaneous
1.Note that these methods throw some sort of exception. Your program will have to handle them so test well.
2.Annotate and format all output for maximum readability.
I dont want someone to do the program, I just need someone to explain to me what Im supposed to do because my text book does not give good examples. This is what I have so far:
import jss2.*;
import java.util.Scanner;
import java.io.*;
public class LinkedBSearch
{
public static void main(String[] args) throws IOException
{
Scanner fileScan;
fileScan = new Scanner(new File("numbers.txt"));
StringTokenizer st = new StringTokenizer("numbers.txt");
int[] ints = new int[Tokenizer.countTokens()];
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
System.out.println(fileScan);
}
}
The professor showed us the program but didnt really explain it in detail so we wouldnt copy what he did. Can someone help me get on the right track. a jss2 folder was provided with over 20 things in it...so confusing!