Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Attached Files http://pastebin.com/cw9AFj2P http://pastebin.com/cwr1Njm9 http://

ID: 3556742 • Letter: A

Question

Attached Files

http://pastebin.com/cw9AFj2P

http://pastebin.com/cwr1Njm9

http://pastebin.com/nyUrQSng

Write a program that reads numbers from a file (provided) and stores them using an insertion sort into a linked list. Write a find method that counts the number of comparisons made when searching for a target element. Use the Node<T> class provided to create the linked list.

A binary search tree is a binary tree with the following properties:

Write a program that creates a binary search tree using the numbers in the data file. Write a find method that counts the number of comparisons made when searching for a target element. Use the BTNode<T> class provided to create the binary tree.

For your linked list, write a driver that creates an output file which displays:

For your binary search tree, write a driver that displays:

A preorder traversal of the list.

An inorder traversal of the list.

A postorder traveral of the list.

Comment on your results:

Explanation / Answer

/* * Java Program to Implement Binary Search Tree */ import java.util.Scanner; /* Class BSTNode */ class BSTNode { BSTNode left, right; int data; /* Constructor */ public BSTNode() { left = null; right = null; data = 0; } /* Constructor */ public BSTNode(int n) { left = null; right = null; data = n; } /* Function to set left node */ public void setLeft(BSTNode n) { left = n; } /* Function to set right node */ public void setRight(BSTNode n) { right = n; } /* Function to get left node */ public BSTNode getLeft() { return left; } /* Function to get right node */ public BSTNode getRight() { return right; } /* Function to set data to node */ public void setData(int d) { data = d; } /* Function to get data from node */ public int getData() { return data; } } /* Class BST */ class BST { private BSTNode root; /* Constructor */ public BST() { root = null; } /* Function to check if tree is empty */ public boolean isEmpty() { return root == null; } /* Functions to insert data */ public void insert(int data) { root = insert(root, data); } /* Function to insert data recursively */ private BSTNode insert(BSTNode node, int data) { if (node == null) node = new BSTNode(data); else { if (data