1 / 13

CS320 Algorithms: Theory and Practice

CS320 Algorithms: Theory and Practice. Representative problems.

jaron
Download Presentation

CS320 Algorithms: Theory and Practice

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. b 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

  4. 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...

  5. 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

  6. 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

  7. 1 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?

  8. 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?

  9. 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.

  10. 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?

  11. 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

  12. 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?

  13. 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.

More Related