Q. In the coin change problem, which approach does a greedy algorithm use?
-
A.
Always take the largest denomination first
-
B.
Take the smallest denomination first
-
C.
Randomly select coins
-
D.
Take coins in pairs
Solution
A greedy algorithm for the coin change problem typically takes the largest denomination first to minimize the number of coins.
Correct Answer:
A
— Always take the largest denomination first
Learn More →
Q. In the context of greedy algorithms, what does 'local optimum' refer to?
-
A.
The best solution overall
-
B.
The best solution in a local neighborhood
-
C.
The worst solution possible
-
D.
A solution that is not feasible
Solution
A local optimum is the best solution within a local neighborhood, which may not lead to the global optimum.
Correct Answer:
B
— The best solution in a local neighborhood
Learn More →
Q. What is a greedy algorithm?
-
A.
An algorithm that makes the best choice at each step
-
B.
An algorithm that explores all possible solutions
-
C.
An algorithm that uses dynamic programming
-
D.
An algorithm that always finds the optimal solution
Solution
A greedy algorithm makes the best choice at each step with the hope of finding the global optimum.
Correct Answer:
A
— An algorithm that makes the best choice at each step
Learn More →
Q. What is the key difference between greedy algorithms and dynamic programming?
-
A.
Greedy algorithms use recursion
-
B.
Dynamic programming considers all possible solutions
-
C.
Greedy algorithms are always optimal
-
D.
Dynamic programming is faster
Solution
The key difference is that dynamic programming considers all possible solutions, while greedy algorithms make local optimal choices.
Correct Answer:
B
— Dynamic programming considers all possible solutions
Learn More →
Q. What is the main drawback of greedy algorithms?
-
A.
They are too slow
-
B.
They may not produce the optimal solution
-
C.
They require more memory
-
D.
They are difficult to implement
Solution
The main drawback of greedy algorithms is that they may not produce the optimal solution for all problems.
Correct Answer:
B
— They may not produce the optimal solution
Learn More →
Q. What is the time complexity of Prim's algorithm for finding the minimum spanning tree using an adjacency matrix?
-
A.
O(V^2)
-
B.
O(E log V)
-
C.
O(V + E)
-
D.
O(V^3)
Solution
Prim's algorithm has a time complexity of O(V^2) when using an adjacency matrix.
Correct Answer:
A
— O(V^2)
Learn More →
Q. Which greedy algorithm is used to solve the activity selection problem?
-
A.
Dijkstra's algorithm
-
B.
Kruskal's algorithm
-
C.
Interval scheduling maximization
-
D.
Prim's algorithm
Solution
The activity selection problem is solved using the interval scheduling maximization greedy algorithm.
Correct Answer:
C
— Interval scheduling maximization
Learn More →
Q. Which of the following is a common application of greedy algorithms?
-
A.
Sorting data
-
B.
Finding the shortest path
-
C.
Job scheduling
-
D.
All of the above
Solution
Job scheduling is a common application of greedy algorithms, particularly in maximizing resource utilization.
Correct Answer:
C
— Job scheduling
Learn More →
Q. Which of the following is NOT a characteristic of greedy algorithms?
-
A.
They make decisions based on current information
-
B.
They do not reconsider previous decisions
-
C.
They guarantee an optimal solution for all problems
-
D.
They are often faster than other algorithms
Solution
Greedy algorithms do not guarantee an optimal solution for all problems; they work well for specific types of problems.
Correct Answer:
C
— They guarantee an optimal solution for all problems
Learn More →
Q. Which of the following problems can be solved using a greedy algorithm?
-
A.
Knapsack problem
-
B.
Minimum spanning tree
-
C.
Shortest path in a graph
-
D.
All of the above
Solution
The minimum spanning tree can be solved using a greedy algorithm, while the knapsack problem is not always solvable by greedy methods.
Correct Answer:
B
— Minimum spanning tree
Learn More →
Showing 1 to 10 of 10 (1 Pages)