Nodes are on same path in a tree or Not
Problem Statement Given a tree and two nodes of tree and the task to check whether these two nodes are on the same path from root to the bottom or not. Example Input Node1 = 1 Node2 = 5 Expected Output Yes Approach The idea is to apply Depth First Search on every node. And … Nodes are on same path in a tree or Not