Which of the following algorithms use Greedy strategy? A. Dijkstra’s algorithm…
2025
Which of the following algorithms use Greedy strategy?
A. Dijkstra’s algorithm
B. Kruskal’s algorithm
C. Huffman coding
D. Bellman-Ford algorithm
Choose the correct answer from the options given below:
- A.
A, B and D Only
- B.
A, B and C Only
- C.
C and D Only
- D.
A and D Only
Attempted by 141 students.
Show answer & explanation
Correct answer: B
Answer: Dijkstra’s algorithm, Kruskal’s algorithm, and Huffman coding.
Explanation:
Dijkstra’s algorithm: Greedy. At each step it selects the vertex with the smallest tentative distance and finalizes that choice, never needing to revise it.
Kruskal’s algorithm: Greedy. It repeatedly picks the smallest-weight edge that does not create a cycle, making locally optimal edge choices to build a minimum spanning forest.
Huffman coding: Greedy. It repeatedly merges the two least-frequent symbols to build an optimal prefix code, making a locally optimal merge at each step.
Bellman-Ford algorithm: Not greedy. It uses repeated relaxation of edges and can update previously made choices based on information found later, which is characteristic of dynamic programming/iterative relaxation rather than a greedy one-pass choice.
Therefore the correct set of algorithms that use a greedy strategy is Dijkstra’s algorithm, Kruskal’s algorithm, and Huffman coding.
A video solution is available for this question — log in and enroll to watch it.