# Greedy Algorithms Multiple Choice Questions (MCQ)

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Greedy Algorithms”.

1. The first step in the naïve greedy algorithm is?
a) adding flows with higher values
b) reversing flow if required
c) analysing the zero flow
d) calculating the maximum flow using trial and error
View Answer

Answer: c
Explanation: The first step in the naïve greedy algorithm is to start with the zero flow followed by adding edges with higher values.

2. Suppose you have coins of denominations 1,3 and 4. You use a greedy algorithm, in which you choose the largest denomination coin which is not greater than the remaining sum. For which of the following sums, will the algorithm produce an optimal answer?
a) 100
b) 10
c) 6
d) 14
View Answer

Answer: a
Explanation: Using the greedy algorithm, three coins {4,1,1} will be selected to make a sum of 6. But, the optimal answer is two coins {3,3}. Similarly, four coins {4,4,1,1} will be selected to make a sum of 10. But, the optimal answer is three coins {4,3,3}. Also, five coins {4,4,4,1,1} will be selected to make a sum of 14. But, the optimal answer is four coins {4,4,3,3}. For a sum of 100, twenty-five coins {all 4’s} will be selected and the optimal answer is also twenty-five coins {all 4’s}.

3. Choose the correct statement from the following.
a) branch and bound is not suitable where a greedy algorithm is not applicable
b) branch and bound divides a problem into at least 2 new restricted sub problems
c) backtracking divides a problem into at least 2 new restricted sub problems
d) branch and bound is more efficient than backtracking
View Answer

Answer: b
Explanation: Both backtracking as well as branch and bound are problem solving algorithms. Branch and bound is less efficient than backtracking. Branch and bound divides a problem into at least 2 new restricted sub problems.
advertisement
advertisement

4. Dijkstra’s Algorithm is the prime example for ___________
a) Dynamic programming
b) Back tracking
c) Branch and bound
d) Greedy algorithm
View Answer

Answer: d
Explanation: Dijkstra’s Algorithm is the prime example for greedy algorithms because greedy algorithms generally solve a problem in stages by doing what appears to be the best thing at each stage.

5. Bellmann Ford Algorithm is an example for ____________
a) Linear Programming
b) Greedy Algorithms
c) Dynamic Programming
d) Branch and Bound
View Answer

Answer: c
Explanation: In Bellmann Ford Algorithm the shortest paths are calculated in bottom up manner which is similar to other dynamic programming problems.

6. Which of the following algorithms is the best approach for solving Huffman codes?
a) greedy algorithm
b) exhaustive search
c) divide and conquer algorithm
d) brute force algorithm
View Answer

Answer: a
Explanation: Greedy algorithm is the best approach for solving the Huffman codes problem since it greedily searches for an optimal solution.

7. Fractional knapsack problem is solved most efficiently by which of the following algorithm?
a) Backtracking
b) Greedy algorithm
c) Dynamic programming
d) Divide and conquer
View Answer

Answer: b
Explanation: Greedy algorithm is used to solve this problem. We first sort items according to their value/weight ratio and then add item with highest ratio until we cannot add the next item as a whole. At the end, we add the next item as much as we can.
advertisement

8. Which of the following is false about the Kruskal’s algorithm?
a) It constructs MST by selecting edges in increasing order of their weights
b) It is a greedy algorithm
c) It uses union-find data structure
d) It can accept cycles in the MST
View Answer

Answer: d
Explanation: Kruskal’s algorithm is a greedy algorithm to construct the MST of the given graph. It constructs the MST by selecting edges in increasing order of their weights and rejects an edge if it may form the cycle. So, using Kruskal’s algorithm is never formed.

More MCQs on Greedy Algorithms:

advertisement

Sanfoundry Global Education & Learning Series – Data Structures & Algorithms.

To practice all areas of Data Structures & Algorithms, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.