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

CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

CS3000:Algorithms&DataJonathanUllman

Lecture1:• CourseOverview• WarmupExercise(Induction,Asymptotics,Fun)

Sep7,2018

Page 2: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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 · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• JerryLanning• OfficeHours:TBD• Location:TBD

• LisaOakley• OfficeHours:Thu12:00-2:00• Location:TBD

• ChandanShankarappa• OfficeHours:Mon2:30-4:30• Location:TBD

TheTATeamOH 2 30 6 30 on MondaysOH 12 00 4 00 on Thursdays

OH on Wednesdays

Page 4: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• TianXia• OfficeHours:Thu2:00-4:00• Location:TBD

• LydiaZakynthinou• OfficeHours:Mon4:30-6:30• Location:TBD

TheTATeam

Page 5: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Whatisanalgorithm?

• Essentiallyallcomputerprograms(andmore)arealgorithmsforsomecomputationalproblem.

Algorithms

Anexplicit,precise,unambiguous,mechanically-executablesequenceofelementaryinstructionsforsolvingacomputationalproblem.

-JeffErickson

Page 6: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• WhatisAlgorithms?

• Abstractandformalizecomputationalproblems• Identifybroadlyusefulalgorithmdesignprinciplesforsolvingcomputationalproblems

• Rigorouslyanalyze propertiesofalgorithms• ThisClass:correctness,runningtime,spaceusage

• Beyond:extensibility,robustness,simplicity,…

Algorithms

Thestudyofhowtosolvecomputationalproblems.

pi find websites about algorth

Page 7: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• WhatisCS3000:Algorithms&Data?

• Proofsareaboutunderstandingandcommunication,notaboutformalityorcertainty• Differentemphasisfromcoursesonlogic

• We’lltalkalotaboutprooftechniquesandwhatmakesacorrectandconvincingproof

Algorithms

Thestudyofhowtosolvecomputationalproblems.Howtorigorouslyprove properiesofalgorithms.TI

Page 8: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Thatsoundshard.WhywouldIwanttodothat?

• BuildIntuition:• How/whydoalgorithmsreallywork?• Howtoattacknewproblems?• Whichdesigntechniquesworkwell?• Howtocomparedifferentsolutions?• Howtoknowifasolutionisthebestpossible?

Algorithms

Page 9: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Thatsoundshard.WhywouldIwanttodothat?

• ImproveCommunication:• Howtoexplainsolutions?• Howtoconvincesomeonethatasolutioniscorrect?• Howtoconvincesomeonethatasolutionisbest?

Algorithms

Page 10: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Thatsoundshard.WhywouldIwanttodothat?

• LearnProblemSolving/Ingenuity• “Algorithmsarelittlepiecesofbrilliance…”-OlinShivers

Algorithms

Page 11: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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 · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Thatsoundshard.WhywouldIwanttodothat?

• Youcanonlygaintheseskillswithpractice!

Algorithms

OHHW

TextbookOther resourcesonline

Page 13: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

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%

TypicalGradeDistributionz P

Page 14: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

CourseStructureEnd12/4

Start9/7

DivideandConquer

DynamicProgramming

GreedyGraphs NetworkFlow

Misc

Textbook:AlgorithmDesignbyKleinbergandTardos

Moreresourcesonthecoursewebsite

FinalTBD

MidtermI10/16

MidtermII11/16

Page 15: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• WeeklyHWAssignments(45%ofgrade)• DueTuesdaysby11:59pm• HW1outnow!DueTue9/18• Noextensions,nolatework• LowestHWscorewillbedroppedfromyourgrade

• Amixofmathematicalandalgorithmicquestions

Homework

Page 16: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• HomeworkmustbetypesetinLaTeX!• Manyresourcesavailable• Manygoodeditorsavailable(TexShop,TexStudio)• IwillprovideHWsource

HomeworkPolicies

onMac

Page 17: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• HomeworkwillbesubmittedonGradescope!• Entrycode:94V4YJ• Signuptoday,orevenrightthisminute!

HomeworkPolicies

use gradescope for regrades

Page 18: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Youareencouragedtoworkwithyourclassmatesonthehomeworkproblems.• Youmaynotusetheinternet• Youmaynotusestudents/peopleoutsideoftheclass

• CollaborationPolicy:• Youmustwriteallsolutionsbyyourself• Youmaynotshareanywrittensolutions• Youmuststateallofyourcollaborators• We reservetherighttoaskyoutoexplainanysolution

HomeworkPolicies

Page 19: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

CourseWebsitehttp://www.ccs.neu.edu/home/jullman/cs3000f18/syllabus.htmlhttp://www.ccs.neu.edu/home/jullman/cs3000f18/schedule.html

Page 20: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• WewillusePiazzafordiscussions• Askquestionsandhelpyourclassmates• Pleaseuseprivatemessagessparingly

• Signuptoday,orevenrightthisminute!

DiscussionForum Note to self Fix Piazza

Page 21: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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 · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

OneMoreThing:Ineedtocounthowmanystudentsareinthisclass!

Page 23: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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)

74 students43 16 seconds

Yes

1 n 2n

Page 24: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

rn

4Th beats 2n if n 4

Page 25: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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

70 student

1 10.73

1

After after every iteration oftheloop

Loopinvariant the sum of the of everyone

standing is n

Page 26: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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

1 n time RecCount takes uth n students

1 n 2TTHE7 Th 3

Page 27: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Recurrence: " 1 = 3," ! = 2 + " ! 2⁄

RunningTime

1 l 3

1 2 2 T l 2 3 5

1 4 2 1 T Z 2t2tT 1 7

1 2n 2T 2 t t 2 t 1 l 2ns 13

m

1 n 2 logan t 3

Page 28: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Claim: Forevery numberofstudents! = 2)" 2) = 2* + 3

RunningTime

Page 29: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• 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 n 2tT ET l 3

Hmt IN 1 27 2m 13

Claim f MEIN HIM is true

1127 5

f me IN if 112 2mt3 then 112M 21mA 13

Page 30: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Claim: Foreverynumberofstudents! = 2)" 2) = 2* + 3

ProofbyInduction

Ht H m T 27 2mi 3

BC 1 2 2 1117 5 o H l is true

S Pick any m assume Hlm

1 2M 2 1 27 Uses the

2 1 2Mt 3 fact thatHln istrue

2 mtl 13

Page 31: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

AsktheAudience

WhoWantstobeaMillionaire?

Page 32: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Claim: Forevery! ∈ ℕ,∑ 21234156 = 22 − 1

• ProofbyInduction:

AsktheAudience

Page 33: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

• Simplecounting: " ! = 2! steps• Recursivecounting:" ! = 2 log; ! + 3 steps

• Butforthisclass,simplecountingwasfaster???

RunningTimehe 74 2 74 148 steps

2x logzG4 3 E 17 steps

243 seconds

70second

steps are not well defined

Page 34: CS3000: Algorithms & Data Jonathan Ullman · •Claim:For every number of students !=2) "2) =2 +3 Proof by Induction Ht H m T 27 2mi 3 BC 1 2 2 1117 5 o H l is true S Pick any m assume

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

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

RunningTime