- By
**jaron** - Follow User

- 112 Views
- Uploaded on

CS320 Algorithms: Theory and Practice. Representative problems.

Download Presentation
## PowerPoint Slideshow about ' CS320 Algorithms: Theory and Practice' - jaron

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### CS320 Algorithms: Theory and Practice

Representative problems

"For me, great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious. But once unlocked, they cast a brilliant new light on some aspect of computing." - Francis Sullivan

The problem solving paradigm

- Formulate it with precision (usually using mathematical concepts, such as sets, relations, and graphs)
- Design an algorithm
- Prove its correctness
- Analyze its running time (complexity)
- Implement respecting the derived complexity

e

h

Interval Scheduling- Input. Set of jobs with start times and finish times.
- Goal. Find maximum cardinality subset of compatible jobs.

a

b

c

d

e

f

g

h

Time

0

1

2

3

4

5

6

7

8

9

10

11

Algorithmic Approach

- The interval scheduling problem is amenable to a very simple solution.
- Now that you know this, can you think of it?
- Hint: Think how to pick a first interval while preserving the longest possible free time...

Weighted Interval Scheduling

- Input. Set of jobs with start times, finish times, and weights.
- Goal. Find maximum weight subset of compatible jobs.

23

12

20

26

13

20

11

16

Time

0

1

2

3

4

5

6

7

8

9

10

11

Bipartite Matching

- Input. Bipartite graph.
- Goal. Find maximumcardinality matching.

A

1

Matching in bipartite graphs can model assignment problems, e.g., assigning jobs to machines, where an edge between a job j and a machine m indicates that m can do job j, or professors and courses.

How is this different from the stable matching problem?

B

2

C

3

D

4

E

4

5

6

Independent Set- Input. Graph.
- Goal. Find maximum cardinality independent set.

subset of nodes such that no two are joined by an edge

2

1

4

5

3

7

6

Can you formulate interval scheduling as an independent set problem?

Independent set problem

- There is no known efficient way to solve the independent set problem.
- What does that mean?
- There is no known algorithm that solves the problem in a polynomial number of steps (polynomial in the number of nodes).
- We can always solve the problem by brute force: check all sub sets and find the largest one that is also an independent set.
- How many subsets of a set of n nodes are there?

Representative Problems / Complexities

- Interval scheduling: n log(n) greedy algorithm.
- Weighted interval scheduling: n log(n) dynamic programming algorithm.
- Bipartite matching: polynomial max-flow based algorithm.
- Independent set: NP-complete (no known polynomial algorithm exists).
- Competitive facility location (see book): PSPACE-complete.

Algorithm

- Algorithm: A series of well defined instructions for solving a given problem.
- Turing defined it as: "like a Turing machine”

Is there an algorithm for every possible problem?

Ulam\'s problem

def f(n) :

if (n==1) return 1

elif (odd(n)) return f(3*n+1)

else return f(n/2)

Does f(n) always stop?

Steps in running f(n) for a few values of n:

1

2, 1,

3, 10, 5, 16, 8, 4, 2, 1

4, 2, 1

5, 16, 8, 4, 2, 1

6, 3, 10, 5, 16, 8, 4, 2, 1

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1

8, 4, 2, 1

9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1

10, 5, 16, 8, 4, 2, 1

Ulam\'s problem

def f(n) :

if (n==1) return 1

elif (odd(n)) return f(3*n+1)

else return f(n/2)

Nobody has found an n for which f does not stop

Nobody has found a proof(so there can be no algorithm deciding this.)

A generalization of this problem has been proven to be undecidable.

- A problem P is undecidable, if there is no algorithm that produces P(x) for every possible input x

Does f(n) always stop?

The Halting Problem is undecidable

- Given a program P and input x

will P stop on x?

We can prove (cs420):

the halting problem is undecidable

i.e. there is no algorithm Halt(P,x) that for any program P and input x decides whether P stops on x.

Download Presentation

Connecting to Server..