Invert Binary Tree

How to Invert Binary Tree or How to convert a binary tree into its mirror tree.

Given a binary tree, we have to write a code to invert it.

Inverting a Binary Tree

Inverting a binary tree means we have to interchange the left and right children of all non-leaf nodes. In simple words, Output is the mirror of the input tree.

How to Calculate Power using Recursion | Pow(x, n)

In this tutorial, I am going to discuss how to calculate power using recursion.

Problem statement – Write a code to implement function pow(x, n), which calculates x raised to the power n (i.e. x^n). In this problem, We don’t have to use in-built function Math.pow.

For example:

Example 1:

Input:   x = 2.00000,    n = 3
Output:  8

Example 2:

Input: x = 2.10000,     n = 3
Output: 9.26100

Example 3:

Input: x = 2.00000,   n = -2
Output: 0.25000