Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Theory of Algorithms - Algorithm and Complexity Analysis - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Algorithm and Complexity Analysis which includes Approximation Algorithms, Coping with Np-Hardness, Fully Polynomial-Time, Brute-Force Algorithms, Approximation Scheme, Knapsack Problem, Profit Subset of Items, Nonnegative Values etc. Key important points are:Theory of Algorithms, Fast Arithmetic, Linear Programming, Network Flow, Huffman Codes, Signal Processing, Routing Internet Packets, Poetry of Computation, College Admissions, Administrative Stuff

Typology: Slides

2012/2013

Uploaded on 03/21/2013

dharmaveer
dharmaveer 🇮🇳

4.5

(2)

54 documents

1 / 9

Toggle sidebar

Related documents


Partial preview of the text

Download Theory of Algorithms - Algorithm and Complexity Analysis - Lecture Slides and more Slides Computer Science in PDF only on Docsity! COS 423: Theory of Algorithms 2 Algorithm. (webster.com) ■ A procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation. ■ Broadly: a step-by-step procedure for solving a problem or accomplishing some end especially by a computer. "Great algorithms are the poetry of computation." Etymology. ■ "algos" = Greek word for pain. ■ "algor" = Latin word for to be cold. ■ Abu Ja’far al-Khwarizmi’s = 9th century Arab scholar. – his book "Al-Jabr wa-al-Muqabilah" evolved into today’s high school algebra text Theory of Algorithms 3 Imagine: A World With No Algorithms Fast arithmetic. ■ Cryptography. Quicksort. ■ Databases. FFT. ■ Signal processing. Huffman codes. ■ Data compression. Network flow. ■ Routing Internet packets. Linear programming. ■ Planning, decision-making. 4 What is COS 423? Introduction to design and analysis of computer algorithms. ■ Algorithmic paradigms. ■ Analyze running time of programs. ■ Data structures. ■ Understand fundamental algorithmic problems. ■ Intrinsic computational limitations. ■ Models of computation. ■ Critical thinking. Prerequisites. ■ COS 226 (array, linked list, search tree, graph, heap, quicksort). ■ COS 341 (proof, induction, recurrence, probability). Docsity.com 5 Administrative Stuff Lectures: (Kevin Wayne) ■ Monday, Wednesday 10:00 - 10:50, COS 104. TA’s: (Edith Elkind, Sumeet Sobti) Textbook: Introduction to Algorithms (CLR). Grading: ■ Weekly problem sets. ■ Collaboration, no-collaboration. ■ Class participation, staff discretion. ■ Undergrad / grad. Course web site: courseinfo.princeton.edu/courses/COS423_S2001/ ■ Fill out questionnaire. 6 Approximate Lecture Outline Algorithmic paradigms. ■ Divide-and-conquer. ■ Greed. ■ Dynamic programming. ■ Reductions. Analysis of algorithms. ■ Amortized analysis. Data structures. ■ Union find. ■ Search trees and extensions. Graph algorithms. ■ Shortest path, MST. ■ Max flow, matching. 7 Approximate Lecture Outline NP completeness. ■ More reductions. ■ Approximation algorithms. Other models of computation. ■ Parallel algorithms. ■ Randomized algorithms. Miscellaneous. ■ Numerical algorithms. ■ Linear programming. College Admissions Sample problem. Algorithm. Analysis. References: The Stable Marriage Problem by Dan Gusfield and Robert Irving, MIT Press, 1989. Introduction to Algorithms by Jon Kleinberg and Éva Tardos. Docsity.com 17 B Preference List Bob Chris Adam C A B D D Doofus A B C D C A Stable Roommate Problem Not obvious that any stable matching exists. Consider related "stable roommate problem." ■ 2N people. ■ Each person ranks others from 1 to 2N-1. ■ Assign roommate pairs so that no unstable pairs. No stable matching. All 3 perfect matchings have unstable pair. E.g., A-C forms unstable pair in lavender matching. 1st 2nd 3rd 18 Propose-And-Reject Algorithm Intuitive method that guarantees to find a stable matching. Initialize each person to be free. while (some man m is free and hasn’t proposed to every woman) w = first woman on m’s list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m Gale-Shapley Algorithm (men propose) 19 Implementation and Running Time Analysis Engagements. ■ Maintain two arrays wife[m], and husband[w]; set equal to 0 if participant is free. ■ Store list of free men on a stack (queue). Preference lists. ■ For each man, create a linked list of women, ordered from favorite to worst. – men propose to women at top of list, if rejected goto next ■ For each woman, create a "ranking array" such that mth entry in array is woman’s ranking of man m. – allows for queries of the form: does woman w prefer m to m’ ? Resource consumption. ■ Time = Θ(N2). ■ Space = Θ(N2). ■ Optimal. { }wmwm to proposed has :),(=Φ 20 Men’s Preference List Wyatt Victor Man 1st A B 2nd C D 3rd C B AZeus Yancey Xavier C D A B B A D C 4th E E 5th A D E E D C B E Women’s Preference List Bertha Amy Man 1st W X 2nd Y Z 3rd Y X VErika Diane Clare Y Z V W W V Z X 4th V W 5th V Z X Y Y X W Z A Worst Case Instance Number of proposals ≤ n(n-1) + 1. ■ Algorithm terminates when last woman gets first proposal. Number of proposals = n(n-1) + 1 for following family of instances. Docsity.com 21 Proof of Correctness Observation 1. Men propose to their favorite women first. Observation 2. Once a woman is matched, she never becomes unmatched. She only "trades up." Fact 1. All men and women get matched (perfect). ■ Suppose upon termination Zeus is not matched. ■ Then some woman, say Amy, is not matched upon termination. ■ By Observation 2, Amy was never proposed to. ■ But, Zeus proposes to everyone, since he ends up unmatched. (contradiction) 22 Proof of Correctness Observation 1. Men propose to their favorite women first. Observation 2. Once a woman is matched, she never becomes unmatched. She only "trades up." Fact 2. No unstable pairs. ■ Suppose (Amy, Zeus) is an unstable pair: each prefers each other to partner in Gale-Shapley matching S*. ■ Case 1. Zeus never proposed to Amy. ⇒ Zeus must prefer Bertha to Amy (Observation 1) ⇒ (Amy, Zeus) is stable. (contradiction) ■ Case 2. Zeus proposed to Amy. ⇒ Amy rejected Zeus (right away or later) ⇒ Amy prefers Yancey to Zeus (women only trade up) ⇒ (Amy, Zeus) is stable (contradiction) Bertha-Zeus Amy-Yancey S* 23 Understanding the Solution For a given problem instance, there may be several stable matchings. ■ Do all executions of Gale-Shapley yield the same stable matching? If so, which one? Fact 3. Yes. Gale-Shapley finds MAN-OPTIMAL stable matching! ■ Man m is a valid partner of woman w if there exists some stable matching in which they are married. ■ Man-optimal assignment: every man receives best valid partner. – simultaneously best for each and every man – there is no stable matching in which any single man individually does better 24 Proof of Fact 3 Proof. ■ Suppose, for sake of contradiction, some man is paired with someone other than best partner. – since men propose in decreasing order of preference, some man is rejected by valid partner ■ Let Yancey be first such man, and let Amy be first valid partner that rejects him. ■ When Yancey is rejected, Amy forms (or reaffirms) engagement with man, say Zeus, whom she prefers to Yancey. ■ Let Bertha be Zeus’ partner in S. ■ Zeus not rejected by any valid partner at the point when Yancey is rejected by Amy (since Yancey is first to be rejected by valid partner). Thus, Zeus prefers Amy to Bertha. ■ But Amy prefers Zeus to Yancey. ■ Thus (Amy, Zeus) is unstable pair in S. Bertha-Zeus Amy-Yancey S Docsity.com 25 Understanding the Solution Fact 4. Gale-Shapley finds WOMAN-PESSIMAL matching. ■ Each woman married to worst valid partner. – simultaneously worst for each and every woman. – there is no stable matching in which any single woman individually does worse Proof. ■ Suppose (Amy, Zeus) matched in S*, but Zeus is not worst valid partner for Amy. ■ There exists stable matching S in which Amy is paired with man, say Yancey, whom she likes less than Zeus. ■ Let Bertha be Zeus’ partner in S. ■ Zeus prefers Amy to Bertha (man optimality). ■ (Amy, Zeus) form unstable pair in S. Bertha-Zeus Amy-Yancey S 26 Understanding the Solution Fact 5. The man-optimal stable matching is weakly Pareto optimal. ■ There is no other perfect matching (stable or unstable), where every man does strictly better. Proof. ■ Let Amy be last woman in some execution of Gale-Shapley (men propose) algorithm to receive a proposal. ■ No man is rejected by Amy since algorithm terminates when last woman receives first proposal. ■ No man matched to Amy will be strictly better off than in man- optimal stable matching. 27 Extensions: Unacceptable Partners Yeah, but in real-world every woman is not willing to marry every man, and vice versa? ■ Some participants declare others as "unacceptable." (prefer to be alone than with given partner) ■ Algorithm extends to handle partial preference lists. Matching S unstable if there exists man m and woman w such that: ■ m is either unmatched in S, or strictly prefers w to his partner in S ■ w is either unmatched in S, or strictly prefers m to her partner in S. Fact 6. Men and women are each partitioned into two sets: ■ those that have partners in all stable matchings; ■ those that have partners in none. 28 Extensions: Sets of Unequal Size Also, there may be an unequal number of men and women. ■ E.g., |M| = 100 men, |W| = 90 women. ■ Algorithm extends. ■ WLOG, assume |W| < |M|. Matching S unstable if there exists man m and woman w such that: ■ m is either unmatched in S, or strictly prefers w to his partner in S; ■ w is either unmatched in S, or strictly prefers m to her partner in S. Fact 7. All women are matched in every stable matching. Men are partitioned into two subsets: ■ men who are matched in every stable matching; ■ men who are matched in none. Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved