Question: 4. (15 points) Consider the following partial code for a binary tree: public class Tree TreeNode root; //constructor and methods not shown public class TreeNode
4. (15 points) Consider the following partial code for a binary tree: public class Tree TreeNode root; //constructor and methods not shown public class TreeNode int value; TreeNode leftchild; TreeNode rightChild; //constructor and methods not shown 3 The following is a method to invert the tree (e.g. if it's a BST from lowest to highest, make it go from highest to lowest). Write the missing code. public static void invertTree (Tree tree) { recursiveInvert(tree root); 1 private static void recursiveInvert(TreeNode node) { //missing code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
