1 / 39

CPSC 320: Intermediate Algorithm Design and Analysis

CPSC 320: Intermediate Algorithm Design and Analysis. July 2, 2014. Instructor and Course Structure. Instructor. Jonatan Schroeder jonatan@cs.ubc.ca Office: ICICS/CS 247 Office hours: Mon/Wed/Fri: 12-1pm Or by appointment. Teaching Assistants. Alireza Shafaei Anupam Srivastava

hetal
Download Presentation

CPSC 320: Intermediate Algorithm Design and Analysis

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. CPSC 320: Intermediate AlgorithmDesign and Analysis July 2, 2014

  2. Instructor and Course Structure

  3. Instructor Jonatan Schroeder jonatan@cs.ubc.ca Office: ICICS/CS 247 Office hours: Mon/Wed/Fri: 12-1pm Or by appointment

  4. Teaching Assistants AlirezaShafaei Anupam Srivastava Jianing Yu Juyoung Moon Reza Babanezhad

  5. Pre-requisites Listed student numbers should come to me after class If you fail to act, you may be dropped from the course Walk-in advising hours: Today 4-5pm: ICCS 391 (Paul Carter) Thu 10:30-11:30am: ICCS 391 (Paul Carter) Thu 3-4pm: ICCS 307 (George Tsiknis) Additional hours may be listed in front of CS main office

  6. Learning Goals Understand techniques used to design efficient algorithms Prove (or disprove) that designed algorithms are correct Prove that designed algorithms are efficient

  7. Course Outline Introduction and basic concepts Asymptotic notation Greedy algorithms Graph theory Amortized analysis Recursion Divide-and-conquer algorithms Randomized algorithms Dynamic programming algorithms NP-completeness

  8. Schedule Lectures: Mon/Wed/Fri 9:30-12:00 Tutorials: T2A: Wed/Fri 1-2pm (Anupam) T2B: Wed/Fri 2-3pm (Anupam) T2C: Wed/Fri 3-4pm (Alireza)

  9. Piazza All course announcements will be posted on Piazza All course-related questions should be asked on Piazza Instructors and TAs will direct your questions to Piazza when relevant Questions including part of a possible solution should be made private Instructors may change a private question to public if deemed useful for other students Students are encouraged to answer questions as well

  10. Piazza (continued) Please take a minute to understand how Piazza works Students’ response is for answering questions, not follow-ups Remember to mark follow-ups as resolved If you found the answer on your own, please add an answer (don’t delete the question)

  11. Marking scheme 6 or 7 assignments: 20% 5 quizzes: 30% Final exam: 50% You must pass the exam to pass the course You must pass in the average of the quizzes You must submit at least five of the assignments

  12. Assignments 6 or 7 assignments Electronic submission or physical copy submission? Please answer a poll on Piazza today before 6PM!!! Assignment 1 will be posted some time today

  13. Quizzes Quiz 1: Wed, July 9 Quiz 2: Wed, July 16 Quiz 3: Wed, July 23 Quiz 4: Wed, July 30 Quiz 5: Wed, August 6 Closed book, closed notes, no calculator Individual component: about 30 minutes Group component: about 15 minutes The group component is to be done in groups of 3-4 Group will solve one of the questions in the individual component

  14. Textbook John Kleinberg and ÉvaTardos, Algorithm Design, Addison-Wesley Publishing company, 2005, ISBN 0-321-29535-8. Optional: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein, Introduction to Algorithms, 3rd edition, MIT Press, 2009, ISBN 0-262-03384-4.

  15. Representative Problem The Stable Matching Problem

  16. Algorithm Sequence of steps to solve a specific task or problem Takes an input, provides a result Each step depends solely on the input and on previous steps Stops in finite time

  17. Algorithm Analysis Does the algorithm terminate? How long does it take (as a function of the input size)? Does it produce a valid result? Is the produced result correct? Is the produced result optimal?

  18. Stable Matching Problem Given men and women Each man ranks all women in preferred order and vice-versa Assign every man to exactly one woman (and vice-versa) Assignment needs to be stable Matching If there is a pair such that prefers over and prefers over then matching is unstable

  19. Example Assume the input: M = {Alvin, Bob, Chuck, Donald} W = {Janice, Kelly, Linda, Madison} Preference ranking:

  20. Example Example matching: (A, L), (B, J), (C, K), (D, M) Unstable (D prefers J, J prefers D)

  21. Example Example matching: (A, L), (B, M), (C, K), (D, J) Stable (no changes give better option)

  22. Example Example matching: (A, L), (B, M), (C, K), (D, J) Stable (no changes give better option)

  23. Discussion What strategies can be used to find a matching? Is there an optimal solution? What defines optimal in this case? Design an algorithm

  24. Gale-Shapley Algorithm set all and to free while some free woman hasn’t proposed to every man do ← the highest-ranking man hasn’t proposed to ifis free then engage else ← s current fiancée ifprefers to then set to free engage return the set of engaged pairs

  25. What should we do now? Does the algorithm produce a matching? Result includes every woman and every man? Each woman is assigned to exactly one man? Each man is assigned to exactly one woman? Is the matching stable? How long (in the worst case) does the algorithm take to terminate?

  26. Complexity Does the algorithm terminate? What happens to a man m as the algorithm progresses? How many times can a man get engaged? What happens to a woman w as the algorithm progresses? How many times can a woman get engaged? What happens overall as the algorithm progresses?

  27. Complexity Theorem: the algorithm terminates in no more than iterations Every iteration contains one proposal Every woman proposes to a man she hasn’t proposed to before At most, each woman proposes to men There are women Number of iterations:

  28. Complexity (discussion) So, does the algorithm run in ? How long to find a free woman? How long to find the preferred man to propose? How long to decide if a man should switch? How long to add/replace a pair from the matching set?

  29. Correctness: Is the result a matching? Does the resulting matching include every woman? Every man, once engaged, is always engaged If there is a free woman, there is a free man Free woman will find a free man Is each man engaged to one woman only? If a man is free during proposal, he will be engaged to one woman If a man is not free, he may replace one woman for another Is each woman engaged to one man only? Only free women propose

  30. Correctness: Is matching stable? By contradiction, suppose matching is unstable and are matched prefers , prefers Three possible cases: never proposed to proposed to , but got rejected proposed to , but got replaced

  31. Correctness: Is matching stable? Case 1: never proposed to proposed to , since they got a matching Since proposes in order of preference, proposed to first Contradiction

  32. Correctness: Is matching stable? Case 2: proposed to , but got rejected Men only reject if they are engaged to someone preferred If rejects when engaged to : prefers to , contradiction If rejects when engaged to someone else () rejects because he prefers over later engages to because he prefers over So, prefers over and over , so prefers over , contradiction

  33. Correctness: Is matching stable? Case 3: proposed to , but got replaced If replaces with , prefers over , contradiction Finally, since all cases generate a contradiction, an unstable matching is never generated by this algorithm QED

  34. Discussion Is the result optimal? What is considered optimal? Who gets it better, women or men? How could this be changed?

  35. Equivalent problems Matching students and co-op jobs Matching medical students and hospitals Matching potential students and college openings

  36. Variations and Similar Problems Hospitals can take several students Number of men and women is different Restrictions and limited preference lists Stable roommate problem (matched pairs from same set) Hospital/student matching with couples Taxis and customers (reduced cost of pick up)

  37. Asymptotic Notation

  38. Machine Model In all algorithms we will assume: Sequential execution One processor Memory position can hold arbitrarily large integer Unless otherwise specified, we will discuss the worst case Best case: usually not very useful Average case: depends on input distribution assumptions

  39. Upper Bound Describes the upper bound of the growth rate of the function Assume

More Related