CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC...

5
1 1/4/17 1 CPSC 121: Models of Computation Section 202 Mondays, Wednesdays and Fridays 10am to 11am Geography 100 CPSC121 – 2016W2 1 CPSC 121: Models of Computation Module 0: Course Introduction CPSC121 – 2016W2 2 Who am I? Alice Gao ([email protected]) Postdoctoral fellow in Computer Science PhD in Computer Science at Harvard University Undergrad in CPSC and MATH at UBC www.cs.ubc.ca/~xigao/ ICICS X563; office hours TBD on the website. CPSC121 – 2016W2 3 Introduce yourself to your neighbours! You will work in pairs for labs and assignments. Maybe you can find a partner now. CPSC121 – 2016W2 4

Transcript of CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC...

Page 1: CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC 121: Models of Computation Section 202 ... Jan 1st Feb 24th Jul 24th Jul 31st Sept

1

1/4/17

1

CPSC121:ModelsofComputation

Section202

Mondays,WednesdaysandFridays10amto11am

Geography100

CPSC121– 2016W2 1

CPSC121:ModelsofComputation

Module0:CourseIntroduction

CPSC121– 2016W2 2

WhoamI?

•AliceGao([email protected])

•PostdoctoralfellowinComputerScience•PhDinComputerScienceatHarvardUniversity•UndergradinCPSCandMATHatUBC•www.cs.ubc.ca/~xigao/

• ICICSX563;officehoursTBDonthewebsite.

CPSC121– 2016W2 3

Introduceyourselftoyourneighbours!

•Youwillworkinpairsforlabsandassignments.•Maybeyoucanfindapartnernow.

CPSC121– 2016W2 4

Page 2: CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC 121: Models of Computation Section 202 ... Jan 1st Feb 24th Jul 24th Jul 31st Sept

2

1/4/17

2

5

Today'slearninggoals

Bytheendofthismodule,youshouldbeableto:•Giveanexampleofhowwecanapplyformalreasoningtoasimple,real-worldtask.

•Giveanexampleofhowacomputationalsolutiontothissimpletaskmightgowrong.

•Describethefour“bigquestions”thatwewillstartansweringinCPSC121.

CPSC121– 2016W2 56

Let'strysorting

Activity:analgorithmtoorderstudentsbydayofbirth.

Howmanyswapsdidyouneedtomake?

CPSC121– 2016W2

Jan 1st Feb 24th Jul 24th Jul 31st Sept 18th

6

7

Computingn(n-1)/2

Computing n(n-1)/2usingDr.Racket:

CPSC121– 2016W2 78

Computingn(n-1)/2[continued]

Computing n(n-1)/2usingJava:

CPSC121– 2016W2

import java.io.*;

public class Compute{

public static void main(String[] args){

int n = Integer.parseInt(args[0]);System.out.println(n * (n-1) / 2);

}}

poirot> java Compute 510

poirot> java Compute 1000499500

poirot> java Compute 1000000-364189984

8

Page 3: CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC 121: Models of Computation Section 202 ... Jan 1st Feb 24th Jul 24th Jul 31st Sept

3

1/4/17

3

Questionstoponder:

•Howcanweprovethatn(n-1)/2isthelargestnumberofswapsneededfornbirthdays?

DirectProoforMathematicalInduction•WhydidourJavaimplementationprintanegativevalue,butnottheRacketimplementation?

Numberrepresentation

CPSC121– 2016W2 910

CPSC121:TheBIG questions

1. Howcanweconvinceourselvesthatanalgorithmdoeswhatit'ssupposedtodo?

2. Howdowedeterminewhetherornotonealgorithmisbetterthananotherone?

3. Howdoesthecomputer(e.g.Dr.Racket)decideifthecharactersofyourprogramrepresentaname,anumber,orsomethingelse?Howdoesitfigureoutifyouhavemismatched""or()?

4. Howcanwebuildacomputerthatisabletoexecuteauser-definedprogram?

CPSC121– 2016W2 10

11

Aworkingcomputer

Aworkingcomputeryouwilllearnaboutinthelabs:

CPSC121– 2016W2 1112

Explorethewebsite

•http://www.ugrad.cs.ubc.ca/~cs121/current/•Youarerequired tobefamiliarwiththecoursewebsite.Ignoranceofinformationonthewebsitemayharmyou.

•Attheminimum,readeverythinginthe“courseinfo”section,skimmingthedetailedlearninggoals.

CPSC121– 2016W2 12

Page 4: CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC 121: Models of Computation Section 202 ... Jan 1st Feb 24th Jul 24th Jul 31st Sept

4

1/4/17

4

13

Gradingscheme

Yourfinalgradewillbecomputedasfollows:•Assignments(5):14%•Labs(9):14%•Pre-classquizzes(10):5%•Midterms(2):24%

•MondayFebruary6th,2017,7pm•MondayMarch20th,2017,7pm

•FinalExam:40%• In-classparticipation/clickers:3%

CPSC121– 2016W2 1314

Lecturetopics

•Mylectureswillfollowtopicslistedunder“LearningGoalsandReadings”onthecoursewebsite.

•Thepagealsocontainstherequiredreadingsforeachlecture.

•http://www.ugrad.cs.ubc.ca/~cs121/2016W2/index.php?page=topics&menu=0&submenu=3

CPSC121– 2016W2 14

15

Pre-classquizzes

•TheyarepostedonConnect.•ThereadingsareonConnectandalsounder“LearningGoalsandReadings”onthecoursewebsite.

•Thefirstquizisduetomorrowevening(Thursday)at7pm.Wewilldoubleyourmarkonthefirstquiztoamaxof100%(Ifyouearnmorethan50%,itwillcountas100%.).

CPSC121– 2016W2 1516

Courseactivities

•ThescheduleforlabsandtutorialsisunderLabsonthecoursewebsite.

•Labs:• Startnextweek(onMondayJan9th,2016).• Youmust attendthelabyouareregisteredfor.• Pre-labworkmustbedonebefore yougettothelab.

•Tutorials:• Startnextweek (onMondayJan9th,2016).• Try toattendthetutorialyouareregisteredfor.

CPSC121– 2016W2 16

Page 5: CPSC 121: Models of Computation - University of British ...cs121/2016W2/slides/gao/0... · CPSC 121: Models of Computation Section 202 ... Jan 1st Feb 24th Jul 24th Jul 31st Sept

5

1/4/17

5

17

Courseactivities[continued]

•Piazza:• Fordiscussions.• https://piazza.com/ubc.ca/winterterm22016/cpsc121• Toregister,usetheaccesscode:[tobeannouncedinclass]

•AcademicConduct:• Pleasereadtherulesonthecoursewebsiteandfollowthem.

•Notfollowingtheseruleswillbeunpleasantforallofus.

CPSC121– 2016W2 1718

Courselearningoutcomes

Afteryoucompletethecourse,youwillbeableto:•modelimportantproblemssothattheyareeasiertodiscuss,reasonabout,solve,andtest.

• learnnewmodelingformalismsmoreeasily.• communicateclearlyandunambiguouslywithotherCSexpertsoncomplextopics.

• characterizealgorithms(CSproblemsolutions),byprovingtheircorrectnessorefficiency.

• criticallyreadproofs:justifyingwhyeachstepiscorrectandjudgingwhattheproofmeans.

• explainhowcomputerswork.

CPSC121– 2016W2 18

19

Firstpre-classquiz

•Firstpre-classquiz:duetomorrow(Thursday)at7pm.

•Sectionstoreadforthequiz(readoneofthem):• Epp,4thedition:2.1and2.4.• Epp,3rdedition:1.1and1.4

•Thereadingsareunder“LearningGoalsandReadings”onthecoursewebsite.

CPSC121– 2016W2 19