Category Archives: Graph

Minimum number of operation required to convert number x into y

Given a initial number x and two operations which are given below: Multiply number by 2. Subtract 1 from the number. The task is to find out minimum number of operation required to convert number x into y using only above two operations. We can apply these operations any number of times. Constraints: 1 <=… Read More »

Roots of a tree which give minimum height

Given an undirected graph, which has tree characteristics. It is possible to choose any node as root, the task is to find those nodes only which minimize the height of tree. Example: In below diagram all node are made as root one by one, we can see that when 3 and 4 are root, height… Read More »