Question
In the design and analysis of algorithms, which of the
following algorithms is based on the greedy approach?Solution
Dijkstra’s algorithm is based on the greedy approach, which selects the locally optimal solution at each step with the goal of finding the shortest path from the source to all other vertices in a graph. The algorithm repeatedly picks the nearest unvisited vertex and calculates the shortest path to all its neighbors, ensuring optimal solutions for each subproblem. Merge Sort : A divide-and-conquer algorithm, not greedy. Depth-First Search : DFS is a traversal technique, not a greedy algorithm. Bellman-Ford Algorithm : This algorithm can handle negative weight edges, but it is not based on the greedy approach. Quick Sort : A divide-and-conquer algorithm, not greedy.
- The current age ratio of Pankaj to Suresh is 7:3. In nine years, Pankaj’s age will be four times Suresh’s age at that time. What is Pankaj’s present ...
In an office, there are 18 employees. The average age of all the employees is 28 years. If the age of three senior managers is included, then the averag...
A is 3 years older than B while C is 5 years younger than B. The ratio of age of A, 6 years hence and age of B, 3 years ago is 4:3. What was age of C, 1...
What is A's present age, if after 25 years his age will be 15 times his age 10 years back?
- The sum of present ages of Rina and Tina is 72 years. After 6 years, the ratio of their ages will be 5:7. Find the difference in their ages.
The ratio of ages of Aryan's grandfather and his father 14 years ago was 5 : 3. The present age of Aryan's grandfather is 7/2 of Aryan's age. If the age...
- The combined present ages of Veer and Raj are 48 years. In 4 years, their age ratio will be 1:3. What is the age difference?
The current average age of three friends, Aravi, Bipasa, and Chinu, is 24 years. The ratio of Chinu's and Diksha's present ages is 4:5, and Bipasa's cur...
7 years ago, Meera’s age was equal to the Heena’s present age. The sum of Meera’s age 10 years from now and Heena’s age 5 years ...
The ratio of the present ages of a son and his father 3:7 and that of his mother and father is 6:7. Four years ago, the ratio of the age of the son that...