Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Mathematical Programming-II Algorithm Design Techniques

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

Mathematical Programming-II

Lecture 5
Algorithm Design Techniques
Zulfiqar Ahmad
Lecturer
Department of Information Technology
Hazara University Mansehra
zulfiqarahmad526@gmail.com

1
Algorithm Design

There are a number of strategies which may be used in the


design of algorithms, including:
• Greedy algorithms
• Divide-and-conquer algorithms
• Dynamic programming
• Backtracking algorithms
Algorithm Design

When searching for a solution, we may be interested in two


types:
• Either we are looking for the optimal solution, or,
• We are interested in a solution which is good enough, where good
enough is defined by a set of parameters
Algorithm Design

For many of the strategies we will examine, there will be certain


circumstances where the strategy can be shown to result in an
optimal solution

In other cases, the strategy may not be guaranteed to do so


well
Algorithm Design

Any problem may usually be solved in multiple ways

The simplest to implement and most difficult to run is brute


force
• We consider all possible solutions, and find that solution which is
optimal
Algorithm Design

Brute force techniques often take too much time to run

We may use brute-force techniques to show that solutions


found through other algorithms are either optimal or close-to-
optimal
Algorithm Design

With brute force, we consider all possible solutions

Most other techniques build solutions, thus, we require the


following definitions

Definition:
• A partial solution is a solution to a problem which could possibly be
extended
• A feasible solution is a solution which satisfies any given requirements
Algorithm Design

Thus, we would say that a brute-force search tests all feasible


solutions

Most techniques will build feasible solutions from partial


solutions and thereby test only a subset of all possible feasible
solutions
Algorithm Design

It may be possible in some cases to have partial solutions


which are acceptable (that is, feasible) solutions to the problem

In other cases, partial solutions may be unacceptable, and


therefore we must continue until we reach a feasible solution
Algorithm Design

We will look at two problems:


• the first requires an exact (optimal) solution,
• the second requires only an approximately optimal solution

In the second case, it would be desirable, but not necessary, to


find the optimal solution
Example

For example, consider the game of Sudoku


The rules are:
• each number must appear once in each row, column, and 3 × 3
outlined square

You are given some


initial numbers, and if they
are chosen appropriately,
there is a unique solution

http://xkcd.com/74/
Example

Using brute force, we could try every possible solution, and


discard those which do not satisfy the conditions

This technique would require us to check 961 ≈ 1.6×1058 possible


solutions

You might also like