1 / 71

Great Theoretical Ideas in Computer Science

15-251. Great Theoretical Ideas in Computer Science. Administrative details. Course Staff. TAs A: JD Nir B: Tim Wilson C: Mark Kai D: Adam Blank E: Sang Tian F: Jasmine Peterson G: Andrew Audibert Shashank Singh. Prof. Ryan O’Donnell. Office hours start Wednesday.

clare
Download Presentation

Great Theoretical Ideas in Computer Science

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. 15-251 Great Theoretical Ideas in Computer Science

  2. Administrative details

  3. Course Staff TAs A: JD NirB: Tim WilsonC: Mark KaiD: Adam BlankE: Sang TianF: Jasmine PetersonG: Andrew Audibert Shashank Singh Prof. Ryan O’Donnell Office hours start Wednesday. Prof. Danny Sleator

  4. Web Sites https://colormygraph.ugrad.cs.cmu.edu = http://www.cs.cmu.edu/~15251 Announcements, Calendar, Notes, Homeworks, … http://piazza.com/cmu/spring2012/15251 Bulletin Board: Questions, Comments, Announcements, …

  5. Textbook There is no textbook. Slides will be posted on the website. Some supplementary notes will also be posted.

  6. Grading 28% Homework(12, lowest one dropped) 5% Quizzes(12, lowest two dropped) 2% Participation 35% Midterms(3, lowest one counts half) 30% Final

  7. Homework Homeworks out/due each Thursday at 11:59pm. They are hard. Must be typeset in LaTeX, submitted online. 5 “late days” for the semester, ≤ 3 per HW. Turned in any time Friday: costs 1 late day Turned in any time Saturday: costs 2 late days Turned in any time Sunday: costs 3 late days After Sunday: grade of 0.

  8. Collaboration On each HW, you may work in a group of ≤ 4 people. You must report who you worked with. You must think about the problems yourself for ≥ 1 hour before discussing them with others. You must write up all solutions by yourself.

  9. Cheating Handled in accordance with university policy: http://www.cmu.edu/policies/documents/Cheating.html You MAY NOT: You MAY: You MUST: sign and return the Honor Code today. Share written work. (Erase all whiteboards.)Get help from anyone besides your HW collaborators, staff. Refer to solutions/materials from earlier versions of 251. Search the web/books for specific homework problems. Get help from others/books/web on ‘general topics’ (“induction”, “random variable”, “diagonalization”) Use tools like Mathematica/Maple/Wolfram Alpha.

  10. Quizzes Every Tuesday (a few exceptions), beginning of class The quiz is DUE AT 3:07pm. Therefore, do NOT be late to class. Tested on material from the prior week. These are designed to be easy, assuming you are keeping up with the lectures.

  11. Midterms Designed to be doable in 1 hour. You will have 3 hours. “Semi-cumulative.” Held Wednesdays, 6pm – 9pm at locations TBD. February 15, March 21, April 18 Mark these dates on your calendar now!

  12. Automatic A There are 4 “Automatic A” problems on website. Solve one, get an A in the course. (Actually +2 letter grades.) All standard homework rules apply (except groups can submit jointly written solution). At most one submission per person/group per semester. They are super-hard… but some easier versions may appear on homeworks or tests…

  13. 15-251: Great Theoretical Ideas in Computer Science Lecture 1 Pancakes With A Problem

  14. Feel free to ask questions

  15. The chef in our place is sloppy; when she prepares pancakes they come out all different sizes. When the waiter delivers them to a customer, he rearranges them (so that the smallest is on top, and so on, down to the largest at the bottom). He does this by grabbing several from the top and flipping them over, repeating this (varying the number he flips) as many times as necessary.

  16. How do we sort this stack?How many flips do we need?

  17. How do we sort this stack?How many flips do we need?

  18. How do we sort this stack?How many flips do we need? 2 flips sufficient 2 flips necessary

  19. How do we sort this stack?How many flips do we need?

  20. Developing Notation: Turning pancakes into numbers 5 52341 2 3 4 1

  21. How do we sort this stack?How many flips do we need? 52341

  22. 4 flips are sufficient 52341 14325 23415 43215 12345

  23. Best way to sort this stack? 52341 Let X be the smallest number of flips that cansort this specific stack. Lower Bound 4 ? ≤X≤ ? Upper Bound

  24. Is 4 a lower bound?What would it take it show that? 52341 A convincing argument that every way of sorting the stack uses at least 4 flips. Lower Bound 4 ? ≤X≤ ? Upper Bound

  25. Four Flips Are Necessary 52341 14325 41325 If we could do it in three flips: First flip has to put 5 on bottom, because… Second flip has to bring 4 to the top, because…

  26. Best way to sort? 52341 Let X be the smallest number of flips that cansort this specific stack. Lower Bound 4 4 ? ≤X≤ ? Upper Bound X = 4

  27. Matching upper and lower bounds! Lower Bound 4 4 ? ≤X≤ ? Upper Bound X = 4

  28. 52341 54321 12345 54123 ? ? ? ? ? 4 1 0 2 P5

  29. 5th Pancake Number Number of flips required to sort when your worst enemy gives you a stack of 5 pancakes P5 = MAX over all 5-stacks Sof MIN # of flips to sort S P5 =

  30. 5th Pancake Number Lower Bound ? ≤P5≤ ? 4 Upper Bound Fact: P5=5 To show P5≥ 5 ? To show P5≤ 5 ? 1. Show a specific 5-stack. 2. Argue that everyway of sorting thisstack uses at least 5 flips. Give a way of sorting every 5-stack using at most 5 flips.

  31. What is Pn for small n? Can you do n = 0, 1, 2, 3 ?

  32. Initial Values of Pn n 0 1 2 3 Pn 0 0 1 3

  33. 1 3 2 P3 = 3 To show P3≥ 3 ? 1. Show a specific 3-stack. 2. Argue that everyway of sorting thisstack uses at least 3 flips. To show P3≤ 3 ? • Biggest one to bottom using ≤ 2 flips. • Smallest one to top using ≤ 1 flip. Give a way of sorting every 3-stack using at most 3 flips.

  34. nth Pancake Number Lower Bound ? ≤Pn≤ ? Upper Bound “What is the best upper boundand lower bound I can prove?”

  35. nth Pancake Number ? ≤Pn≤ ? Upper Bound Let’s start by thinking about an upper bound.

  36. Upper Bound on Pn Fix the biggest pancake. ? ? ? ? ? ? ? ? ? ? n

  37. Upper Bound on Pn Fix the biggest pancake. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? n n−1 n n

  38. Upper Bound on Pn Fix pancake #n ≤ 2 flips Fix pancake #n−1≤ 2 flips ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? n 1 2 Fix pancake #n−2≤ 2 flips 3 • • • • • n • Fix pancake #3≤ 2 flips n-3 n-2 n-1 Fix pancake #2≤ 2 flips n ≤ 2n−2

  39. Upper Bound on Pn Fix pancake #n ≤ 2 flips Fix pancake #n−1≤ 2 flips ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? n ? ? Fix pancake #n−2≤ 2 flips 3 • • • • • n • Fix pancake #3≤ 2 flips n-3 n-2 n-1 Fix pancake #2≤1 flip n ≤2n−3

  40. Upper Bound on Pn Fix pancake #n ≤ 2 flips Bring-To-Top Method shows Pn≤ 2n−3 assuming n ≥ 2. Fix pancake #n−1≤ 2 flips Fix pancake #n−2≤ 2 flips • • • Fix pancake #3≤ 2 flips Fix pancake #2≤1 flip ≤2n−3

  41. ?  Pn 2n−3 Let’s think about a lower bound for Pn 1. Show a specific n-stack. 2. Argue that everyway of sorting thisstack uses a lot of flips.

  42. Lower Bound on Pn • • • 17 15 13 11 9 7 5 • • • This stack seemspretty painful!

  43. Breaking-Apart Argument • • • 17 15 13 11 9 7 5 • • • Suppose the stack has an adjacent pair which should not be adjacent in the end. Spatula must go between them at least once. (“Adjacent pair” includes bottom pancake and the plate.) Each flip can achieve at most 1 “break-apart”.

  44. Proof of Pn ≥ n S n•••642n-1• ••531 Case 1: n is even. S contains n adjacent pairs which need to be broken apart, each necessitating at least one flip. 4 2 31 Detail: Assuming n > 4.

  45. Proof of Pn ≥ n S n-1•••642n• ••531 Case 2: n is odd. S contains n adjacent pairs which need to be broken apart, each necessitating at least one flip. 2 31 Detail: Assuming n > 3.

  46. Upper and lower bounds are within a factor of 2. n  Pn 2n−3 (for n > 4) Upper Bound Lower Bound

  47. From any n-stack to sorted n-stack in ≤ Pn Slight Digression From sorted n-stack to any n-stack in ≤ Pn ? Reverse the sequence of flips used to sort! Hence: any n-stack to any n-stack in ≤ 2Pn Is there a better way?

  48. S: 4,3,5,1,2 T: 5,1,4,3,2 Any Stack S to Any Stack T in ≤ Pn 1,2,3,4,5 3,4,1,2,5 “new S” Rename the pancakes in T to be 1,2,3,…,n Rewrite S using the new naming scheme In ≤ Pn flips can sort “new S”. The same sequence of flips also brings S to T.

  49. The Known Pancake Numbers Pn n 12345678910111213141516171819 013457891011131415161718192022

  50. P20 is unknown It is either 23 or 24, we don’t know which. 20•19•18•⋅⋅⋅•2•1 = 20! possible 20-stacks 20! = 2.43 × 1018 (2.43 exa-pancakes) Brute-force analysis is impossible!

More Related