The maximum depth of a binary tree is the number of nodes from the root down to the furthest leaf node. In other words, it is the height of a binary tree.
Consider the binary tree illustrated below:
The maximum depth, or height, of this tree is ; node and node are both four nodes away from the root.
The algorithm uses recursion to calculate the maximum height: