In this problem, we are given input as the reference to the root of a binary tree. We need to find the diameter of the tree. We solve this using two approaches:
Approach 1: Using recursion
Approach 2: Using DFS
A tree is an extensively used data structure in the world of programming. Every node in a tree can have more further subdivisions. The bottom-most nodes of a tree that have no sub-divisions, are called the leaf nodes.
DIAMETER OF A TREE: It is defined as the number of nodes on the longe...
Published on November 15, 2020 07:13