NT1330 Unit 1 Assignment Analysis

Words: 1550
Pages: 7

Assignment Description: For this assignment I needed to construct a program that ran in the Jeliot environment to develop a binary tree, search the tree for a value within it, and return the number of iterations it took to obtain the value. The program needed to be able to allow a variable number of integers to be entered by providing a prompt to the user as well as a method to indicate all wanted integers had been entered. After all integers had been entered, the program then needed to prompt the user for a search value. Once the search value was entered the program needed to perform a search of the developed binary tree and report back to the user the number of iterations of the search procedure were needed to find the requested value.

Algorithm Function:
…show more content…
} public static void main(String[] args) { BinaryTree testTree = new BinaryTree(); char input; int addValue, sValue; System.out.println("Beginning BST"); System.out.println("You will be prompted to enter an integer in the" + " Jeliot window to add to the Binary Search Tree. After" + " adding an integer, you will be prompted to enter a" + " character. If you are done adding integers, enter 'd'. If" + " you are not, enter any other character."); do{ System.out.println("Add an integer to the BST: "); addValue = Input.readInt(); testTree.insert(addValue);

System.out.println("Type 'd' if done: "); input = Input.readChar(); } while (input != 'd' && input !=