Question description

  1. How to know if a vertex is a parent or children?
  2. In the given sample input is 2 a beautiful vertex ?Because it has 2 neighbours while its neighbours - 1, 3 & 4 have only one neighbours each ?
  1. You are given that the vertex with lowest value is the master (root) node, similarly highest value vertex would be a leaf. The graph is spread from low values to high.
  2. 2 is a beautiful vertex bcoz it has 3 and 4 as its children while only 1 parent i.e. 1.

Sir why 1 is not a beautiful vertex as it has no parent and 1 children i.e. 2 ?

1 is the root node. It will always be a beautiful vertex according to the conditions. Thats why we dont count it one

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.