Explore BrainMass
Share

C++: function swapSubTrees for class binaryTreeType

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Write a function, swapSubTrees, that swaps all of the left and right subtrees of a binary tree. Add this function to the class binaryTreeType and create a program to test this function.

Attached is the class binaryTreeType to work on along with what I think is an algorithm to do the logic. I need the function to work and a program to test it. Can write a main method right under the binaryTreeType class I have attached.

© BrainMass Inc. brainmass.com March 21, 2019, 7:41 pm ad1c9bdddf
https://brainmass.com/computer-science/searching/cplusplus-function-swapsubtrees-class-binarytreetype-302698

Attachments

Solution Preview

Your existing code did not have insert function to add new nodes to tree, and it had some bugs as well. All those issues have also been fixed in attached 302698.cpp (tested with "g++ -Wall"). Please ...

Solution Summary

Solution also shows what a sample run of the program will look like, that verifies the subtrees swapping.

$2.19