Menu

[Solved]Write Java Code Following Given Directions Proceeding Practice Problem Listed Directions Q37262088

Write a java code by following the given directions and thenproceeding to the practice problem listed after the directions.

Given the two binary trees below: 15 4 (3 18 16) (20 4 » Write a method called swapSubtrees, which swaps all of the left and

Problem: a) Create a TreeNode class with the following methods: default constructor, two overloaded constructors, copy constr

Given the two binary trees below: 15 4 (3 18 16) (20 4 » Write a method called swapSubtrees, which swaps all of the left and right subtrees in the above binary trees. Add this method to the class BinaryTree and create a program to test this method for these 2 trees. Show the original trees and the resulting trees Note: To test your algorithm, first create a binary search tree Write a method called singleParent, which returns the number of nodes in a binary tree that have only one child for the 2 trees given in the above. Add this method to the class Binary Tree and create a program to test this method Note: To test your algorithm, first create a binary search tree. e Start with an empty heap, and enter ten items with priorities 1 through 10 Draw the resulting heap – Now remove three entries from the heap that you created in the above exercise, Draw the resultina heap Problem: 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 BinarySearch Tree objects. Use default and overloaded constructors. For tree one: call the methods make Tree (makes a complete tree), print Tree, swapSubtrees, print Tree. Simliar for tree two. Also, print out the number of single parents in each tree. Define make Tree and print Tree in this class. Show transcribed image text Given the two binary trees below: 15 4 (3 18 16) (20 4 » Write a method called swapSubtrees, which swaps all of the left and right subtrees in the above binary trees. Add this method to the class BinaryTree and create a program to test this method for these 2 trees. Show the original trees and the resulting trees Note: To test your algorithm, first create a binary search tree Write a method called singleParent, which returns the number of nodes in a binary tree that have only one child for the 2 trees given in the above. Add this method to the class Binary Tree and create a program to test this method Note: To test your algorithm, first create a binary search tree. e Start with an empty heap, and enter ten items with priorities 1 through 10 Draw the resulting heap – Now remove three entries from the heap that you created in the above exercise, Draw the resultina heap
Problem: 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 BinarySearch Tree objects. Use default and overloaded constructors. For tree one: call the methods make Tree (makes a complete tree), print Tree, swapSubtrees, print Tree. Simliar for tree two. Also, print out the number of single parents in each tree. Define make Tree and print Tree in this class.

Expert Answer


Answer to Write a java code by following the given directions and then proceeding to the practice problem listed after the directi… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *