2078 5

CSC325 ยท 2078 ยท 5 marks

What do you mean by optimization problem? Explain the greedy strategy for algorithm design to solve optimization problems.

What do you mean by optimization problem? Explain the greedy strategy for algorithm design to solve optimization problems. [5]

Design and Analysis of AlgorithmsChapter 4: Greedy AlgorithmsOptimization Problems and Optimal Solution, Introduction of

Quick answer

An optimization problem is the problem of finding the best solution from all feasible solutions. The goal is either to maximize or minimize some objective function subject to given constraints.

Optimization Problem and Greedy Strategy

Optimization Problem

Optimization problems can be divided into two categories:

  • Discrete Optimization: Variables are discrete (e.g., integer values). Examples include knapsack problem, shortest path problem, etc.
  • Continuous Optimization: Variables are continuous. These include constrained problems and multimodal problems.

Greedy Strategy for Algorithm Design

The greedy strategy (or greedy method) is an algorithmic approach that builds up a solution piece by piece, always choosing the next piece that offers the most immediate or local benefit (the locally optimal choice) at each step, with the hope of finding a global optimum.

Key Idea

At each step, make the choice that looks best at the moment without reconsidering previous choices.

Characteristics of Greedy Strategy

PropertyDescription
Greedy Choice PropertyA globally optimal solution can be arrived at by making locally optimal (greedy) choices at each step.
Optimal SubstructureAn optimal solution to the problem contains optimal solutions to its subproblems.
No BacktrackingOnce a choice is made, it is never reconsidered.

General Steps of Greedy Algorithm

  1. Initialize an empty solution set.
  2. Select the best available candidate (greedy choice) from the remaining options.
  3. Check feasibility: Determine if the selected candidate can be added to the solution without violating constraints.
  4. Add the candidate to the solution if feasible.
  5. Repeat steps 2-4 until a complete solution is obtained.

Example: Activity Selection Problem

Given a set of activities with start and finish times, select the maximum number of non-overlapping activities.

Greedy Choice: Always select the activity that finishes earliest among the remaining compatible activities.

Activities sorted by finish time:
A1(1,3), A2(2,5), A3(4,6), A4(6,8)

Step 1: Select A1 (earliest finish = 3)
Step 2: A2 overlaps with A1, skip
Step 3: Select A3 (start=4 >= finish of A1=3)
Step 4: Select A4 (start=6 >= finish of A3=6)

Result: {A1, A3, A4} --> Maximum 3 activities

Advantages of Greedy Strategy

  • Simple and easy to implement.
  • Generally faster than dynamic programming (often O(n log n) or O(n)).
  • Works well when greedy choice property and optimal substructure hold.

Limitations

  • Does not always produce a globally optimal solution.
  • Cannot be applied to all optimization problems (e.g., 0/1 Knapsack does not yield optimal result with greedy).

Common Problems Solved Using Greedy Strategy

  • Fractional Knapsack Problem
  • Huffman Coding
  • Prim's and Kruskal's Minimum Spanning Tree
  • Dijkstra's Shortest Path Algorithm
  • Activity Selection Problem

In summary, the greedy strategy solves optimization problems by making the locally best choice at each step, which leads to an efficient and often optimal solution when the problem satisfies the greedy choice property and optimal substructure.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.