CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1:...
Transcript of CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1:...
![Page 1: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/1.jpg)
CS3000:Algorithms&DataJonathanUllman
Lecture1:• CourseOverview• WarmupExercise(Induction,Asymptotics,Fun)
Sep7,2018
![Page 2: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/2.jpg)
• Name:JonathanUllman• CallmeJon• NEUsince2015• Office:623ISEC• OfficeHours:Wed10:30-12:00
• Research:• Privacy,Cryptography,MachineLearning,GameTheory• Algorithmsareatthecoreofallofthese!
Me
![Page 3: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/3.jpg)
• JerryLanning• OfficeHours:TBD• Location:TBD
• LisaOakley• OfficeHours:Thu12:00-2:00• Location:TBD
• ChandanShankarappa• OfficeHours:Mon2:30-4:30• Location:TBD
TheTATeam
![Page 4: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/4.jpg)
• TianXia• OfficeHours:Thu2:00-4:00• Location:TBD
• LydiaZakynthinou• OfficeHours:Mon4:30-6:30• Location:TBD
TheTATeamM 2 30 6 30U
Th 12 00 4 00
![Page 5: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/5.jpg)
• Whatisanalgorithm?
• Essentiallyallcomputerprograms(andmore)arealgorithmsforsomecomputationalproblem.
Algorithms
Anexplicit,precise,unambiguous,mechanically-executablesequenceofelementaryinstructionsforsolvingacomputationalproblem.
-JeffErickson
![Page 6: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/6.jpg)
• WhatisAlgorithms?
• Abstractandformalizecomputationalproblems• Identifybroadlyusefulalgorithmdesignprinciplesforsolvingcomputationalproblems
• Rigorouslyanalyze propertiesofalgorithms• ThisClass:correctness,runningtime,spaceusage
• Beyond:extensibility,robustness,simplicity,…
Algorithms
Thestudyofhowtosolvecomputationalproblems.
meds sortingnumbersthe shortest
rate home
![Page 7: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/7.jpg)
• WhatisCS3000:Algorithms&Data?
• Proofsareaboutunderstandingandcommunication,notaboutformalityorcertainty• Differentemphasisfromcoursesonlogic
• We’lltalkalotaboutprooftechniquesandwhatmakesacorrectandconvincingproof
Algorithms
Thestudyofhowtosolvecomputationalproblems.Howtorigorouslyprove properiesofalgorithms.as
![Page 8: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/8.jpg)
• Thatsoundshard.WhywouldIwanttodothat?
• BuildIntuition:• How/whydoalgorithmsreallywork?• Howtoattacknewproblems?• Whichdesigntechniquesworkwell?• Howtocomparedifferentsolutions?• Howtoknowifasolutionisthebestpossible?
Algorithms
![Page 9: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/9.jpg)
• Thatsoundshard.WhywouldIwanttodothat?
• ImproveCommunication:• Howtoexplainsolutions?• Howtoconvincesomeonethatasolutioniscorrect?• Howtoconvincesomeonethatasolutionisbest?
Algorithms
![Page 10: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/10.jpg)
• Thatsoundshard.WhywouldIwanttodothat?
• LearnProblemSolving/Ingenuity• “Algorithmsarelittlepiecesofbrilliance…”-OlinShivers
Algorithms
![Page 11: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/11.jpg)
• Thatsoundshard.WhywouldIwanttodothat?
• GetRich:• Manyoftheworld’smostsuccessfulcompanies(notablyGoogle)beganwithalgorithms.
• Understandthenaturalworld:• Brains,cells,networks,etc.oftenviewedasalgorithms.
• Fun:• Yes,seriously,fun.
Algorithms
![Page 12: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/12.jpg)
• Thatsoundshard.WhywouldIwanttodothat?
• Youcanonlygaintheseskillswithpractice!
Algorithms
![Page 13: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/13.jpg)
CourseStructureEnd12/4
FinalTBD
Start9/7
MidtermI10/16
MidtermII11/16
• HW=45%• Exams=55%
• MidtermI=15%• MidtermII=15%• Final=25%
A, 30%
B, 50%
C,20%
TypicalGradeDistribution
![Page 14: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/14.jpg)
CourseStructureEnd12/4
Start9/7
DivideandConquer
DynamicProgramming
GreedyGraphs NetworkFlow
Misc
Textbook:AlgorithmDesignbyKleinbergandTardos
Moreresourcesonthecoursewebsite
FinalTBD
MidtermI10/16
MidtermII11/16
![Page 15: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/15.jpg)
• WeeklyHWAssignments(45%ofgrade)• DueTuesdaysby11:59pm• HW1outnow!DueTue9/18• Noextensions,nolatework• LowestHWscorewillbedroppedfromyourgrade
• Amixofmathematicalandalgorithmicquestions
Homework7 IO HU
![Page 16: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/16.jpg)
• HomeworkmustbetypesetinLaTeX!• Manyresourcesavailable• Manygoodeditorsavailable(TexShop,TexStudio)• IwillprovideHWsource
HomeworkPolicies
![Page 17: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/17.jpg)
• HomeworkwillbesubmittedonGradescope!• Entrycode:94V4YJ• Signuptoday,orevenrightthisminute!
HomeworkPolicies
![Page 18: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/18.jpg)
• Youareencouragedtoworkwithyourclassmatesonthehomeworkproblems.• Youmaynotusetheinternet• Youmaynotusestudents/peopleoutsideoftheclass
• CollaborationPolicy:• Youmustwriteallsolutionsbyyourself• Youmaynotshareanywrittensolutions• Youmuststateallofyourcollaborators• We reservetherighttoaskyoutoexplainanysolution
HomeworkPolicies
![Page 19: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/19.jpg)
• WewillusePiazzafordiscussions• Askquestionsandhelpyourclassmates• Pleaseuseprivatemessagessparingly
• Signuptoday,orevenrightthisminute!
DiscussionForum
![Page 20: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/20.jpg)
CourseWebsitehttp://www.ccs.neu.edu/home/jullman/cs3000f18/syllabus.htmlhttp://www.ccs.neu.edu/home/jullman/cs3000f18/schedule.html
![Page 21: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/21.jpg)
• Iteachtwosections:TF1:35andTF3:25• Thesesectionsarecompletelyinterchangeable• YoumaycollaborateonHWacrossmysections• YoumaygotoOHforanyofmyTAs
• Prof.NealYoungteachesanothersection• Noformalrelationshipwithmysections• Willcoververysimilartopicsandsharesomematerials• YoumaynotcollaboratewithProf.Young’ssection• YoushouldnotgotoOHforProf.Young’sTAs
WhatAbouttheOtherSections?
![Page 22: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/22.jpg)
OneMoreThing:Ineedtocounthowmanystudentsareinthisclass!
![Page 23: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/23.jpg)
• Isthiscorrect?• Howlongdoesthistakewith! students?
SimpleCounting
SimCount:Find first studentFirst student says 1Until we’re out of students:Go to next studentNext student says (what last student said + 1)
41 students22 38 seconds
I
1 n 2n steps
![Page 24: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/24.jpg)
rn
rn 11rn
i s
4th beats 2h unless n is tiny
![Page 25: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/25.jpg)
• Isthiscorrect?Why?
RecursiveCounting
RecCount:Everyone set your number to 1 Everyone stand upUntil only one student is standing:Pair up with a neighbor, wait if you don’t find oneFor each pair:Sum up your numbersSit down if you are the taller person in the pair
Say your number
4958.70 seconds
1
Loop InvariantAfter each iteration the sum of the sof
all people standing is n
![Page 26: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/26.jpg)
• Howlongdoesthistakewith! students?
RecursiveCounting
RecCount:Everyone set your number to 1 Everyone stand upUntil only one student is standing:Pair up with a neighbor, wait if you don’t find oneFor each pair:Sum up your numbersSit down if you are the taller person in the pair
Say your number
n 2x
TH T 27 2 1 12 steps1 l 3
![Page 27: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/27.jpg)
• Recurrence: " 1 = 3," ! = 2 + " ! 2⁄
RunningTime1 27 2 412
mo 1 l 3
reT 2 2 t 1 l 2 3
mT 4 2 t 1 2 2 2 3
1 Zm 2 2 2 1 2 3 2Mt 3mem
1 n 2 login 13
![Page 28: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/28.jpg)
• Claim: Forevery numberofstudents! = 2)" 2) = 2* + 3
RunningTime
![Page 29: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/29.jpg)
• Claim: Foreverynumberofstudents! = 2)" 2) = 2* + 3
• Induction: “automatically”proveforevery*• InductiveHypothesis: Let+ * bethestatement" 2) = 2* + 3
• BaseCase:+ 1 istrue• InductiveStep: Forevery* ≥ 1,+ * ⟹ + * + 1• Conclusion: statementistrueforevery*
ProofbyInduction 1 2n 2tT 2m
T l 3
tf m C IN Them 2m 13
Fm e IN Hlm is true 3 Clm
Hh Hk HID Hlm
![Page 30: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/30.jpg)
• Claim: Foreverynumberofstudents! = 2)" 2) = 2* + 3
ProofbyInduction 1 2n 2tT 2m
T 1 3
IH H m is Tl2m 2mt3
BC Hln is true b c 1 2 2 7111 2 3
IS FixanymHN To show Hlm Hfmti
112Mt 2 tt 2m
2tkmzyndtIfYIsE
2 mti1t3 Hlmtilistnets
![Page 31: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/31.jpg)
AsktheAudience
WhoWantstobeaMillionaire?
![Page 32: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/32.jpg)
• Claim: Forevery! ∈ ℕ,∑ 21234156 = 22 − 1
• ProofbyInduction:
AsktheAudience
![Page 33: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/33.jpg)
• Simplecounting: " ! = 2! steps• Recursivecounting:" ! = 2 log; ! + 3 steps
• Butforthisclass,simplecountingwasfaster???
RunningTime n 41
re 82steps
I 15 steps
![Page 34: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1: • Course Overview • Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018](https://reader033.fdocuments.us/reader033/viewer/2022051813/60329bd3d2006577961f89a0/html5/thumbnails/34.jpg)
• Simplecounting:" ! = 2! seconds• Recursivecounting:" ! = 30 log; ! + 45 seconds
• Comparealgorithmsbyasymptotics!• Log-timebeatslinear-timeas! → ∞
RunningTime
n120