Using the BTNode class, write a new static method of the BTNode class to meet th
ID: 3660540 • Letter: U
Question
Using the BTNode class, write a new static method of the BTNode class to meet the following specification. No recursion is needed.
public static void subswap(BTNode root)
// Precondition: Root is the root reference of a binary tree.
// Postcondition: If root is non-null, then the original left subtree below this root has been moved and is now the right subtree, and the original right subtree is now the left subtree.
// Example original tree: Example new tree:
Explanation / Answer
public void static subswap(BTNode root) { int *temp; if(root!=null) { temp=root->left; root->left=root->right; root->right=temp; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.