import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.PrintWriter; import java.util.Iterator; import java.util.Scanner; public class TestMTree { /** * @param args */ public static void main(String[] args) throws FileNotFoundException,IncorrectFormatException{ int arity=4; //MTree MTree1= new MTree(arity); BTree MTree1= new BTree(arity); Scanner inputStream = null; /** Set up input and output files */ try { inputStream= new Scanner(new FileReader("small1.txt")); } catch(FileNotFoundException e) { System.out.println("input file was not found"); System.out.println("or could not be opened"); System.exit(0); } //read in the elements while (inputStream.hasNext()){ try { if (!inputStream.hasNextInt()) throw new IncorrectFormatException(inputStream.next()); else {MTree1.insert(inputStream.nextInt()); System.out.println("So far the nodes in DFS order are: "); System.out.println(MTree1.outputNodes());System.out.println("\n"); } } catch (IncorrectFormatException error){ System.out.println("incorrect format" + error); System.exit(0); } } System.out.println("The original set is:\n"+MTree1 + "\n\n\n"); System.out.println("And has size " + MTree1.getSize()); System.out.println("set contains 53 is: " + MTree1.contains(53)); System.out.println("set contains 125 is: " + MTree1.contains(125)); System.out.println("The inorder traversal of the tree is: "); System.out.println(MTree1); //write out the nodes in full System.out.println("And the nodes in DFS order are: "); System.out.println(MTree1.outputNodes()); } }