Problem #1

a) Create a TreeNode class with the following methods: default constructor, two overloaded constructors, copy constructor, getValue, getLeft, getRight, setValue, setLeft, setRight

b) Create a BTInterface with the following abstract methods: getRoot, setRoot, isEmpty, swapSubtrees, singleParent, preorder, postOrder, inOrder, insert

c) Create an abstract BinaryTree class that implements the interface. Include the default constructor, a private helper method called checkNode for singleParent() and toString. Make insert an abstract method.

d) Derive a BinarySearchTree class from BinaryTree with the following methods: default constructor, overloaded constructor (use a variable length parameter), insert.

e) Create a TreeDemo class that creates two BinarySearchTree objects. Use default and overloaded constructors. For tree one: call the methods makeTree (makes a complete tree), printTree, swapSubtrees, printTree. Similar for tree two. Also, print out the number of single parents in each tree. Define makeTree and printTree in this class.

Problem #2

a) Create a HeapPriorityQueue interface with the following abstract methods: isEmpty, isFull, enqueue, dequeue, reheapifyUpward, reheapifyDownward, reposition.

b) Create the HeapPriorityQueue class. Have heapArray hold maxSize of 250 entries. Also, include the methods: default constructor, toString.

c) Create HeapOverflowException and HeapUnderflowException classes

d) Create a HeapDemo class that creates a HeapPriorityQueue object and insert the values 1-10 into the heap. Print out the heap and remove two values from the heap. Print the resulting heap. Try and show the resulting tree with the nodes on their appropriate levels along with their branches.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.