[wpdm_package id=’1354′] Algorithm: [sourcecode lang=”cpp”] void DeleteBinaryTree(tree_node *root) { if(!root) return; DeleteBinaryTree(root->left); DeleteBinaryTree(root->right); free(root); } [/sourcecode]

[wpdm_package id=’1359′] Algorithm: Return true if both the trees are empty. Return false if only one of the tree is empty. Return false if root…

[wpdm_package id=’1361′] Algorithm: [sourcecode lang=”cpp”] int FindLevelWithMaxSum() { tree_node *temp; int level=0, maxLevel=0; std::queue<tree_node *> Q; int currentSum=0, maxSum=0; if(!root) return 0; Q.push(root); Q.push(NULL); while(!Q.empty())…

[wpdm_package id=’1363′] Algorithm: Use Recursion. Find the left node and corresponding right node each time using recursion. Swap the nodes. [sourcecode lang=”cpp”] void MirrorOfBinaryTree(tree_node *root)…

Question – How do we implement 2 Stacks using 1 Array? One stack routines should not show a exception unless every slot in array is…

[wpdm_package id=’1365′] Algorithm: Use Recursion. Store the data in each path in an array while you traverse. Traverse the left subtree and the right subtree.…

[wpdm_package id=’1349′] Algorithm: Use recursion. Find the height of the left subtree. Find the height of the right subtree. Check which is maximum. The maximum…

[wpdm_package id=’1421′] Question – Reverse a string Conditions – i. I have to reverse word by word. ii. When I reverse a word the Last…

[wpdm_package id=’1373′] Algorithm: Use the level order traversal or Breadth First Traversal. Insert the element where we find the left/right node as NULL. [sourcecode lang=”cpp”]…

[wpdm_package id=’1375′] Algorithm: Create a Stack. Till the half of the string length, push the characters of the string into the stack. If it is…