CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 1:...

34
CS3000: Algorithms & Data Jonathan Ullman Lecture 1: Course Overview Warmup Exercise (Induction, Asymptotics, Fun) Sep 7, 2018

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

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

• 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

• 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

• 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

• 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

• 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

• 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

• 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

• 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

• 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

• 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

• 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

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

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

• 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

• 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

• 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

• 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

• 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

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

• 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

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

• 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

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

• 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

• 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

• 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

• 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

• 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

• 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

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

• 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

• 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

• Simplecounting:" ! = 2! seconds• Recursivecounting:" ! = 30 log; ! + 45 seconds

• Comparealgorithmsbyasymptotics!• Log-timebeatslinear-timeas! → ∞

RunningTime

n120