Objective: Given a binary Tree, write an algorithm to find the maximum width.

Note: Maximum width of a tree is nothing but the Max(nodes at each level).

Input: A Binary Tree

Output: Maximum width of a given tree.

Example:

Approach:

The solution of this problem is very simple, Do level order traversal and in recursive calls count the number of nodes at each level and keep track of Max of them and at the end return the max.

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________