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:...
CS3000:Algorithms&DataJonathanUllman
Lecture1:• CourseOverview• WarmupExercise(Induction,Asymptotics,Fun)
Sep7,2018
• Name:JonathanUllman• CallmeJon• NEUsince2015• Office:623ISEC• OfficeHours:Wed10:30-12:00
• Research:• Privacy,Cryptography,MachineLearning,GameTheory• Algorithmsareatthecoreofallofthese!
Me
• JerryLanning• OfficeHours:TBD• Location:TBD
• LisaOakley• OfficeHours:Thu12:00-2:00• Location:TBD
• ChandanShankarappa• OfficeHours:Mon2:30-4:30• Location:TBD
TheTATeam
• 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
• Whatisanalgorithm?
• Essentiallyallcomputerprograms(andmore)arealgorithmsforsomecomputationalproblem.
Algorithms
Anexplicit,precise,unambiguous,mechanically-executablesequenceofelementaryinstructionsforsolvingacomputationalproblem.
-JeffErickson
• WhatisAlgorithms?
• Abstractandformalizecomputationalproblems• Identifybroadlyusefulalgorithmdesignprinciplesforsolvingcomputationalproblems
• Rigorouslyanalyze propertiesofalgorithms• ThisClass:correctness,runningtime,spaceusage
• Beyond:extensibility,robustness,simplicity,…
Algorithms
Thestudyofhowtosolvecomputationalproblems.
meds sortingnumbersthe shortest
rate home
• WhatisCS3000:Algorithms&Data?
• Proofsareaboutunderstandingandcommunication,notaboutformalityorcertainty• Differentemphasisfromcoursesonlogic
• We’lltalkalotaboutprooftechniquesandwhatmakesacorrectandconvincingproof
Algorithms
Thestudyofhowtosolvecomputationalproblems.Howtorigorouslyprove properiesofalgorithms.as
• Thatsoundshard.WhywouldIwanttodothat?
• BuildIntuition:• How/whydoalgorithmsreallywork?• Howtoattacknewproblems?• Whichdesigntechniquesworkwell?• Howtocomparedifferentsolutions?• Howtoknowifasolutionisthebestpossible?
Algorithms
• Thatsoundshard.WhywouldIwanttodothat?
• ImproveCommunication:• Howtoexplainsolutions?• Howtoconvincesomeonethatasolutioniscorrect?• Howtoconvincesomeonethatasolutionisbest?
Algorithms
• Thatsoundshard.WhywouldIwanttodothat?
• LearnProblemSolving/Ingenuity• “Algorithmsarelittlepiecesofbrilliance…”-OlinShivers
Algorithms
• Thatsoundshard.WhywouldIwanttodothat?
• GetRich:• Manyoftheworld’smostsuccessfulcompanies(notablyGoogle)beganwithalgorithms.
• Understandthenaturalworld:• Brains,cells,networks,etc.oftenviewedasalgorithms.
• Fun:• Yes,seriously,fun.
Algorithms
• Thatsoundshard.WhywouldIwanttodothat?
• Youcanonlygaintheseskillswithpractice!
Algorithms
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
CourseStructureEnd12/4
Start9/7
DivideandConquer
DynamicProgramming
GreedyGraphs NetworkFlow
Misc
Textbook:AlgorithmDesignbyKleinbergandTardos
Moreresourcesonthecoursewebsite
FinalTBD
MidtermI10/16
MidtermII11/16
• WeeklyHWAssignments(45%ofgrade)• DueTuesdaysby11:59pm• HW1outnow!DueTue9/18• Noextensions,nolatework• LowestHWscorewillbedroppedfromyourgrade
• Amixofmathematicalandalgorithmicquestions
Homework7 IO HU
• HomeworkmustbetypesetinLaTeX!• Manyresourcesavailable• Manygoodeditorsavailable(TexShop,TexStudio)• IwillprovideHWsource
HomeworkPolicies
• HomeworkwillbesubmittedonGradescope!• Entrycode:94V4YJ• Signuptoday,orevenrightthisminute!
HomeworkPolicies
• Youareencouragedtoworkwithyourclassmatesonthehomeworkproblems.• Youmaynotusetheinternet• Youmaynotusestudents/peopleoutsideoftheclass
• CollaborationPolicy:• Youmustwriteallsolutionsbyyourself• Youmaynotshareanywrittensolutions• Youmuststateallofyourcollaborators• We reservetherighttoaskyoutoexplainanysolution
HomeworkPolicies
• WewillusePiazzafordiscussions• Askquestionsandhelpyourclassmates• Pleaseuseprivatemessagessparingly
• Signuptoday,orevenrightthisminute!
DiscussionForum
CourseWebsitehttp://www.ccs.neu.edu/home/jullman/cs3000f18/syllabus.htmlhttp://www.ccs.neu.edu/home/jullman/cs3000f18/schedule.html
• Iteachtwosections:TF1:35andTF3:25• Thesesectionsarecompletelyinterchangeable• YoumaycollaborateonHWacrossmysections• YoumaygotoOHforanyofmyTAs
• Prof.NealYoungteachesanothersection• Noformalrelationshipwithmysections• Willcoververysimilartopicsandsharesomematerials• YoumaynotcollaboratewithProf.Young’ssection• YoushouldnotgotoOHforProf.Young’sTAs
WhatAbouttheOtherSections?
OneMoreThing:Ineedtocounthowmanystudentsareinthisclass!
• 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
rn
rn 11rn
i s
4th beats 2h unless n is tiny
• 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
• 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
• 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
• Claim: Forevery numberofstudents! = 2)" 2) = 2* + 3
RunningTime
• 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
• 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
AsktheAudience
WhoWantstobeaMillionaire?
• Claim: Forevery! ∈ ℕ,∑ 21234156 = 22 − 1
• ProofbyInduction:
AsktheAudience
• Simplecounting: " ! = 2! steps• Recursivecounting:" ! = 2 log; ! + 3 steps
• Butforthisclass,simplecountingwasfaster???
RunningTime n 41
re 82steps
I 15 steps
• Simplecounting:" ! = 2! seconds• Recursivecounting:" ! = 30 log; ! + 45 seconds
• Comparealgorithmsbyasymptotics!• Log-timebeatslinear-timeas! → ∞
RunningTime
n120