Data Structures & AlgorithmsVery hardICPC regional · matroid greedy
Problem: Which two properties define a matroid, which is what makes the greedy algorithm optimal?
- A. Commutativity and associativity
- B. Monotonicity and convexity
- C. Planarity and bipartiteness
- D. Hereditary property and the exchange property
Correct answer: D. Hereditary property and the exchange property
Greedy is optimal on matroids because every independent set can be extended by the exchange property.
More Coding Interview Problems questions
- Problem: Which algorithm finds shortest paths in a grid where each cell weight is 0 or 1?
- Problem: Which technique counts subarrays with sum at most K in a non-negative array in O(n)?
- Problem: What is the time complexity of subset-sum over n items with a bitset of width W (up to 10^5)?
- Problem: What is the purpose of the low-link value in Tarjan's strongly connected components algorithm?
- Problem: What is the worst-case complexity of the SPFA (queue-based Bellman-Ford) shortest path algorithm?
- Problem: Which property must hold for Huffman coding to produce an optimal prefix code?