Here are some scenarios where can use Greedy algorithms directly. These are classified into a few categories:
Optimization
Optimisation with absolute differences
When we need to find a target \(T\) in an array \(a\) that minimises cost, we can use the following heuristics:
- Problems where the cost is \(∑∣a_i−T∣\) → minimized by the median.
- Problems where the cost is \(∑(a_i−T)^2\) → minimized by the mean.
This extends to the following more general case of:
- Sum of distances in Manhattan metric → median (per dimension)
- Sum of distances in Euclidean metric → mean (per dimension)