data structures and algorithms
play

Data Structures and Algorithms A procedure for solving a - PowerPoint PPT Presentation

Algorithm definitions Data Structures and Algorithms A procedure for solving a mathematical problem (as of finding Tyler Moore the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation.


  1. Algorithm definitions Data Structures and Algorithms “ A procedure for solving a mathematical problem (as of finding Tyler Moore the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation. ” — webster.com CS 2123, The University of Tulsa “ An algorithm is a finite, definite, effective procedure, with some input and some output. ” Some slides created by or adapted from Dr. Kevin Wayne. For more information see — Donald Knuth http://www.cs.princeton.edu/~wayne/kleinberg-tardos 2 Why study algorithms? Matching med-school students to hospitals Internet. Web search, packet routing, distributed file sharing, ... Goal. Given a set of preferences among hospitals and med-school students, Biology. Human genome project, protein folding, … design a self-reinforcing admissions process. Computers. Circuit layout, databases, caching, networking, compilers, … Computer graphics. Movies, video games, virtual reality, … Unstable pair: student x and hospital y are unstable if: Security. Cell phones, e-commerce, voting machines, … ・ x prefers y to its assigned hospital. Multimedia. MP3, JPG, DivX, HDTV, face recognition, … ・ y prefers x to one of its admitted students. Social networks. Recommendations, news feeds, advertisements, … Physics. N-body simulation, particle collision simulation, … Stable assignment. Assignment with no unstable pairs. ⋮ ・ Natural and desirable condition. ・ Individual self-interest prevents any hospital–student side deal. We emphasize algorithms and techniques that are useful in practice. 6 3

  2. Stable matching problem Perfect matching Goal. Given a set of n men and a set of n women, find a "suitable" matching. Def. A matching S is a set of ordered pairs m – w with m ∈ M and w ∈ W s.t. ・ Participants rank members of opposite sex. ・ Each man m ∈ M appears in at most one pair of S . ・ Each man lists women in order of preference from best to worst. ・ Each woman w ∈ W appears in at most one pair of S . ・ Each woman lists men in order of preference from best to worst. Def. A matching S is perfect if | S | = | M | = | W | = n . favorite least favorite favorite least favorite 1 st 2 nd 3 rd 1 st 2 nd 3 rd 1 st 2 nd 3 rd 1 st 2 nd 3 rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus men's preference list women's preference list a perfect matching S = { X–C, Y–B, Z–A } 4 5 Unstable pair Stable matching problem Def. Given a perfect matching S , man m and woman w are unstable if: Def. A stable matching is a perfect matching with no unstable pairs. ・ m prefers w to his current partner. ・ w prefers m to her current partner. Stable matching problem. Given the preference lists of n men and n women, find a stable matching (if one exists). Key point. An unstable pair m–w could each improve partner by joint action. ・ Natural, desirable, and self-reinforcing condition. ・ Individual self-interest prevents any man–woman pair from eloping. 1 st 2 nd 3 rd 1 st 2 nd 3 rd 1 st 2 nd 3 rd 1 st 2 nd 3 rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Bertha and Xavier are an unstable pair a perfect matching S = { X–A, Y–B, Z–C } 6 7

  3. Stable roommate problem Gale-Shapley deferred acceptance algorithm Q. Do stable matchings always exist? An intuitive method that guarantees to find a stable matching. A. Not obvious a priori. G ALE –S HAPLEY ( preference lists for men and women ) Stable roommate problem. ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ I NITIALIZE S to empty matching. ・ 2 n people; each person ranks others from 1 to 2 n – 1 . WHILE (some man m is unmatched and hasn't proposed to every woman) ・ Assign roommate pairs so that no unstable pairs. w ← first woman on m 's list to whom m has not yet proposed. IF ( w is unmatched) 1 st 2 nd 3 rd no perfect matching is stable Add pair m – w to matching S . Adam B C D A – B , C – D ⇒ B – C unstable ELSE IF ( w prefers m to her current partner m ' ) Bob C A D A – C , B – D ⇒ A – B unstable Remove pair m' – w from matching S . Chris A B D A – D , B – C ⇒ A – C unstable Add pair m – w to matching S . Doofus A B C ELSE w rejects m . Observation. Stable matchings need not exist for stable roommate problem. RETURN stable matching S . ________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ 8 9 Gale-Shapley demo Gale-Shapley demo men's preference list men's preference list 1 st 2 nd 3 rd 4 th 5 th 1 st 2 nd 3 rd 4 th 5 th Victor Bertha Amy Diane Erika Clare Victor Bertha Amy Diane Erika Clare Wyatt Diane Bertha Amy Clare Erika Wyatt Diane Bertha Amy Clare Erika Xavier Bertha Erika Clare Diane Amy Xavier Bertha Erika Clare Diane Amy Yancey Amy Diane Clare Bertha Erika Yancey Amy Diane Clare Bertha Erika Zeus Bertha Diane Amy Erika Clare Zeus Bertha Diane Amy Erika Clare STOP (stable matching) women's preference list women's preference list 1 st 2 nd 3 rd 4 th 5 th 1 st 2 nd 3 rd 4 th 5 th Amy Zeus Victor Wyatt Yancey Xavier Amy Zeus Victor Wyatt Yancey Xavier Bertha Xavier Wyatt Yancey Victor Zeus Bertha Xavier Wyatt Yancey Victor Zeus Clare Wyatt Xavier Yancey Zeus Victor Clare Wyatt Xavier Yancey Zeus Victor Diane Victor Zeus Yancey Xavier Wyatt Diane Victor Zeus Yancey Xavier Wyatt Erika Yancey Wyatt Zeus Xavier Victor Erika Yancey Wyatt Zeus Xavier Victor 2 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend