I thought that my mistake is I am assuming the ith node to become the temple. But i should consider the node with maximum no of outdegrees. I can calculate outdegree but then how to remove those nodes from outdegree which are visited and how to sort outdegree datas tructure for maximum outdegree node
6 test cases failed out of 1
Hello @piyush.bansal8158625,
There is a very small issue with your program that is causing the wrong output:
The size of the visited array.
You are not counting for vertex v.
Solution:
bool *visited=new bool[v+1]{false};
Hope, this would help.
Give a like if you are satisfied.
Well caught the mistake. Thanks a lot