Surgical Critical Care Philip Goodney, MD October 26th, 2005.
Introduction to Computer Sciencebytes.usc.edu/files/cs109/slides/CSCI109-Lecture1...Introduction to...
Transcript of Introduction to Computer Sciencebytes.usc.edu/files/cs109/slides/CSCI109-Lecture1...Introduction to...
Introduction to Computer ScienceCSCI109
AndrewGoodneyFall2019
Lecture1:IntroductionAugust26,2019
China– Tianhe-2
Purpose of this Course
u Introducecomputerscienceasadiscipline,abodyofknowledge,andadomainofscience/engineeringv Thefocusisonideasandconceptsv Significantamountsofreadingbutnoprogramming(seeCSCI103L)
u Whatiscomputing,acomputer,science(andengineering)?u Howdocomputerswork?
v Computers,architectures,datastructuresandalgorithms,programming,operatingsystems,networks,abstractmachinesandtheory,artificialintelligence,robotics,humancomputerinteraction,…
u Whatiscomprisedwithinthedomainofcomputing?v Comprehendingitscontentandstructurev Appreciatingitspast,presentandfuture
u Provideabasisuponwhichyoucanbuildthroughouttheremainderofyourcomputingeducation
2
Purpose of this Course
3
Course Outline
4
ìSurvey:https://tinyurl.com/y2cot2r5Password:CS109Fall2019
5
1.Howmanycollegelevelcomputerclasseshaveyoucompleted?a.0 b.1 c.2 d.3 e.4ormore
2.Howmanyyearsofcomputerprogramminghaveyoudone?a.0 b.1 c.2 d.3 e.4ormore
3.Howmanyprogramminglanguagesdoyouknow?a.0 b.1 c.2 d.3 e.4ormore
4.AreyoutakingCS103concurrentlywiththisclass?a.Yes b.No
5.YourreasonfortakingCS109isa. Requiredforyourcurrentmajororminor.b. Notrequiredforyourcurrentmajororminorbutisrequiredforamajororminoryouwanttoadd(ormoveto).
c. NotrequiredforyourcurrentmajororminornorforamajororminoryouareconsideringbutyouareinterestedinlearningaboutComputerScience.
ìLogistics
6
Instructor and TAsu Instructor:AndrewGoodneyu Office:PHE406u OfficeHour: Seecoursewebsite
7
u ContactInfo:[email protected]
TeachingAssistants(TAs)
Office: TBDOfficeHour:TBD
Artem [email protected]
Office:TBDOfficeHour:TBD
Note:Officehoursstartnextweek!Seecoursewebsitefordetails.
Important Info
u Classv Location:SGM123 Days&Time:M12:00-13:50
uTherearenodiscussionorquizsectionsu Co-requisite:CSCI103L
v Thereisnoprerequisite
u RequiredTextbookv ComputingforOrdinaryMortals,St.Amant,R.OxfordUniversityPress,2013
u Syllabusisonhttp://bytes.usc.edu/cs109/u Slideswillbepostedon“bytes”uOtherreadingmaterialwillbemadeavailablethere
8
Homework (30%)
u Fourhomeworks (7.5%each)u Collaborationiswelcomeonthehomework
v Butcopyingisnotpermittedu Youareallowedatotaloftwolatedaysonthehomeworkv Onehomeworkmaybe2dayslate,ortwomaybe1daylate,withnopenalty
v Oncelatedaysareused,onedaylatereducesthescoreby25%,twodayslatereducesthescoreby50%,nocreditisgivenforthreeormoredayslate
v All4homeworks mustbesubmittedtoearnapassinggradeu Allhomeworksubmissionsmustbetyped
9
Quizzes (5%), Midterm (30%),Final (35%)
u ~8in-classquizzesuNocollaborationispermittedonthequizzesu Bestfivescoreswillberetainedsoquizzesareworth5%ofyourgrade
u 1midterm:worth30%ofyouroverallgrade
u 1finalexam(cumulative):worth35%ofyouroverallgrade
10
Quiz policy
Thereareabsolutelynomakeupquizzes.Ifyouneedtobeawayfromclasstoseeadoctor,ortoplayonasportsteam,themissedquizzesneedtocomefromyourquotaofthetwo‘allowedmisses.’Pleaseplanonthis.Ifyoumissquizzesearlierinthesemesterbecauseyoudon’tcometoclassfornogoodreasonandthenarefacedwithasituationlaterinthesemesterwhereyouneedtoseethedoctor,pleasedonotrequestamedicalexemption.Youshouldmarshalthequotaof‘allowedmisses’carefully.Thequizzeswillbeadministeredinclassbutitisimpossibletopredictexactlywhenduringthelecturetheywilloccur.Ifyoucometoclassafterthequizforthatdayhasbeenadministered(orleavebeforeitisadministered),youarenotentitledtoamakeuportohavethequizre-administeredforyou.
11
How is the final grade assigned?
u Eachhomework,quizandexamreceivesarawnumericscoreu Bestfivequizscoresareretainedu Weightedcombinationofrawnumericscoresproducestotalrawscore(outof100)
u Thetotalrawscoreisnormalized– i.e.eachtotalrawscoreisdividedbythe95thpercentilerawscoreintheclass.ScoresareNOTrounded.
u Recentsemestershaveseenthe95th percentilescorebe~95%v Thismeanstocalculateyournormalizedscoreyoudivideyourrawscoreby.95
u Gradeboundariesdrawntogroupsimilarnormalizedscoresinsamefinalgradev Startingpointforboundariesis:>93:A,>90:A-,>87:B+,>83:B,>80:B-,>68:C,
>65:C-,>63:D+,>60:D,>55:D-
u Ifyou“need”aparticulargradeforthiscourse,thetimetoworryaboutthatisnow! 12
Other Misc. Itemsu Gradingdisputes/reviews
v Whenyouhomeworkisgraded,pleasereviewitinatimelymanner.Ifyouwouldlikeclarificationorreviewofagradeditem,youmaydosoinoneoftwoways:seetheTAsinofficehours(preferred)ormakean“instructorsonly”postonPiazza.Eitherway,youmustmakeanyrequestswithinoneweekofthehomeworkbeingreturned.
u DSPstudentsv IfyouhaveanaccommodationletterfromDSP,pleasee-mailittomeassoonas
possible.Specificaccommodationswillbediscussedinadvanceoftheexams.
u CECS->CSv IfyouwereaCECSstudent,andyouareswitchingtopureCS,pleaseletmeknow
(email)
u Piazzav https://piazza.com/usc/fall2019/csci109/v WeusePiazzaforadiscussionboard,pleaseuseittoaskforhelpwiththe
homeworkorothercourserelatedquestionsv Thisletsallstudentsseetheresponses=moreefficientthane-mail! 13
ìWhat is a Computer?
14
Computer or Not?
15
Standard Definitions (dictionary.com)
u Anelectronicdevicedesignedtoacceptdata,performprescribedmathematicalandlogicaloperationsathighspeed,anddisplaytheresultsoftheseoperations
u Aprogrammablemachinethatperformshigh-speedprocessingofnumbers,aswellasoftext,graphics,symbols,andsoundv Allcomputerscontainacentralprocessingunit thatinterpretsandexecutesinstructions;
inputdevices,suchasakeyboardandamouse,throughwhich dataandcommandsenterthecomputer;memorythatenablesthecomputertostoreprogramsanddata;andoutputdevices,suchasprintersanddisplayscreens,thatshowtheresultsafterthecomputerhasprocesseddata
u Anelectronicdevicethatstoresandmanipulatesinformationv Unlikeacalculator,itisabletostoreaprogram andretrieveinformationfromitsmemory
u Amachinethatcanbeprogrammedtomanipulatesymbols
u Apersonwhocomputes;computist.v 1640s:“onewhocalculates”
16Aninformationtransformer
Types of Information
u Bits:0/1,T/F,True/False,Yes/Nov Andstringsofbits,suchas010110
u Numbers:5,101,-3,3.14159,i,πv Andnumericexpressions,suchas(3+2)
u Statementsinlogic:"x At(x,USC)Ù Person(x)Þ Smart(x)u Letters,words,sentences,paragraphs,articles,booksu Audio,imageandvideofilesu URLs(suchashttp://www/google.com)andwebpagesu Databasesu …
17
Binary
u Moderncomputersusebinaryarithmeticu Examples:
v 2410 =16+8=24 +23
=1 *24+1 *23+0 *22+0 *21+0 *20
= 110002v 9010 =64+16+8+2
=1 *26+0 *25+1 *24+1 *23+0 *22+1 *21+0 *20
=10110102v 101112 =1 *24+0 *23+1 *22+1 *21+1 *20
=16+4+2+1=2310
18
Information Transformation
u Convertonebodyofinformationtoanotherv Thatis,compute
u Example:Booleanalgebrav Informationexpressedinbits:0/1(orF/T)v Operationstransforminputbitstoyieldoutputbits
u AND,OR,NOT,…
19
AND 0 10 0 01 0 1
OR 0 10 0 11 1 1
NOT 0 11 0
XOR 0 10 0 11 1 0
AND(0,1)è 0 OR(0,1)è 1
AND(1,1)è 1 0OR(0,0)è
Information Transformation
20
AND 0 10 0 01 0 1
OR 0 10 0 11 1 1
NOT 0 11 0
Whatisthetruthtableforf(x,y)=AND(OR(x,y),NOT(AND(x,y)))?x y OR(x,y) AND(x,y) NOT(AND(x,y)) AND(OR(x,y),NOT(AND(x,y)))0 0 0 0 1 00 1 1 0 1 11 0 1 0 1 11 1 1 1 0 0
f 0 10 0 11 1 0
CS Topic: representing numbers with binary
u Hereisourfirst“real”CStopic!u Getcomfortablewithlookingatbinarynumbers!u Nohard(easier?)thanbase10u Whybinary?
v Weuseelectroniccomputers(99.99999999%ofusanyway)v Circuitscanbeonoroff:twostates->binaryrepresentation
u Booleanoperationsandalgebraisonewayofcomputingwithbinarynumbers
u Firsthomework(andquiz)hasyoulookatbinarylogicandtransformingnumbersbase10<->base2
21
More on Information Transformation
u Otherexamplesv Mathematicalcalculations– (10+2)/2=6– andlogicalproofsv Solvingpuzzlesv Sortinglists:4,2,1,3,6,5v Computationalthinkingv Transformingdataintoinsights(bigdata oranalytics)v Transformingknowledgeintodecisionsaboutwhatactionstoperformv Literary,musicalandartisticcomposition
u Hardware enablesimplementingtransformationsu Software (programs)control(s)transformationsu Algorithms areabstractdescriptionsoftransformations
22
Computational Thinking
u “thoughtprocessesinvolvedinformulatingproblemsandtheirsolutionssothatthesolutionsarerepresentedinaformthatcanbeeffectivelycarriedoutbyaninformation-processingagent” (Cuny,Snyder,Wing)
v wayofsolvingproblems,designingsystems,andunderstandinghumanbehaviorthatdrawsonconceptsfundamentaltocomputerscienceu Toflourishintoday'sworld,computationalthinkinghastobeafundamentalpart
ofthewaypeoplethinkandunderstandtheworldv creatingandmakinguseofdifferentlevelsofabstraction,tounderstandand
solveproblemsmoreeffectivelyv thinkingalgorithmically andwiththeabilitytoapplymathematicalconcepts
suchasinduction todevelopmoreefficient,fair,andsecuresolutionsv understandingtheconsequencesofscale,notonlyforreasonsofefficiency
butalsoforeconomicandsocialreasons
23
Humansthinking(i.e.,transforminginformation)todeviseproceduresforexecutionbyinformationtransformers(humanand/ormachine)
Computer or Not?
24
Implications
u Definingcomputersintermsoftheirfunctionality…v Stripsawayancillaryattributespreviouslythoughtessential
u Machine,electronic,speed,explicitprogrammability,…
v Enablesappreciatingthefullscopeofcomputersandcomputing
u Facilitatesrecognitionof“natural”computersv Brain:Thoughtispreeminentlyinformationtransformationv Embryonicdevelopment:BasedoninstructionswritteninDNAv Evolution:CombinesandmodifiesinformationinDNAv Immunesystem:Includespatternrecognizers,memory,…
25
DavidBaltimore:“Howbiologybecameaninformationscience”RichardDawkins:“Thedifferencebetweenlifeandnon-lifeisa
matternotofsubstancebutofinformation”
ìComputer HistoryLooms,thediscretemachineabstraction,andthefirstcomputerprograms
26
A History of Human-Built Computers
u Althoughcomputerscan(andhavebeen)builtusingallkindsofhardware,moderncomputingreallytookoffwiththeinventionofelectroniccomputerswhichwereprecededbymechanicalcomputers
u AhistoryofcomputingandtheJacquardLoomuMechanicalComputers
v TheDifferenceandAnalyticalEnginesv TheHollerithMachine
u ElectronicComputersv FromEDSACtotheMacbook
27
Reading:St.Amant: Introduction,Ch.1andCh.2
Before Mechanical Computers
Electroniccomputerswereprecededbymechanicalcomputersandmechanicalcomputerswereprecededby…
…looms
28
A Simple Mechanical Loom
u Pressingtreadlescausesharnessestoliftthreadsu Theshuttleslidesacrossthreadundertheliftedthreadsu Thenthethreadsareloweredu Pressingtreadlescausesharnessestoliftthreadsu Theshuttleslidesacrossthreadundertheliftedthreadsu Thenthethreadsareloweredu Pressingtreadlescausesharnessestoliftthreadsu Theshuttleslidesacrossthreadundertheliftedthreadsu Thenthethreadsareloweredu …u Whatkindofpatternsdoesthisproduce?
29
Discrete Machines: State
uHowdoestheloombehaveasafunctionoftime?u Atanygiventimeasetofthreadsisraisedandtherestarelowered
uWritingdownthesequenceofraised(andlowered)threadstellsusthestepsthemachinewentthroughtoproducethecloth/tapestry/whatever
u Thepatternofraised(andlowered)threadsiscalledthestate ofthemachine
30
CS Topic: State
u StateisaverycommonCSconceptu Herewehavethestateofaphysicalmachine
u InCSwetalkaboutthe“state”ofanobjectv Ofadatabasev Ofarobotv Ofa“state-machine”(finite,Turing,etc…)v Ofasystem(physicalorvirtual)v …
u Thenweneedawaytodescribethestatev Givesusthenotionofanencoding
31
CS Topic: Discrete Machines, State and Encoding
u Choosingastaterepresentationtakesskill.Thestateshouldbev Parsimonious:itshouldbea“small”descriptorofwhatthemachineis
doingatanygiventimev Adequate:itshouldbe“bigenough”tocaptureeverything“interesting”
aboutthemachine
u Thesearesometimescontradictory.Theyarealsoqualitativeanddependonwhatbehaviorofthemachinewewanttodescribe
uUsuallyyouneedavocabulary(encoding)todescribestate.Inthecaseofaloom,statecanbeexpressedasabinarypattern(1forraised,0forlowered)
32
Discrete Machines: Abstraction
u Theloomisadiscretemachinev Stateisbinarypattern– i.e.discretev Thenotionoftimeisdiscrete– i.e.timeismodeledasproceedinginstepsor
finitechunks
uMoreprecisely,theloomcanbeusefullymodeledasadiscretemachinev Becauseofcoursebeingaphysicaldevicethereisvariation,nothingis
exactlyprecisev Butmodelingthemachineasdiscreetisgoodenoughandworksforthis
purpose
u Thisisanexampleofanabstraction – akeyconceptinComputerScience 33
CS topic: Abstraction
u Oneofthefundamental“things”wedoinCSu Reducingordistillingaproblemorconcepttotheessentialqualitiesv Simplesetofcharacteristicsthataremostrelevanttotheproblem
u Many(most,all)ofwhatwedoinengineeringandcomputerscienceinvolvesabstractions
u Heretheabstractionismodellingtheloomasasimplediscreetstatemachinev Makesitpossibletounderstandv Andmakesitpossibleto“program”theloom
34
Weaving Complex Patterns
u Howtoproducemorecomplexpatterns?u Earlysolutionwashuman– thedrawloom
v Masterweavercallsoutwhichthreadstoliftv Drawboy liftsthreadsv Masterweaverthreadstheshuttlev Masterweavercallsoutwhichthreadstoliftv Drawboy liftsthreadsv Masterweaverthreadstheshuttlev Masterweavercallsoutwhichthreadstoliftv Drawboy liftsthreadsv Masterweaverthreadstheshuttlev …
35
The Jacquard Loom (1801): Mechanism
uMechanism:v Threadsattachedtospring-loadedrodsv Springsmakeallthreadswanttoliftunlessstoppedsomehow
v Ametal‘card’withholesisinsertedintothepathofthethreads
v Aholeinthecorrespondingplaceallowsathreadtolift.Noholearreststhethreadmotionandstopsitfromlifting
u TheJacquardLoom(fromtheTeachingPaletteviaYouTube)
36
The Jacquard Loom: Programming
uWeavingbecomestheprocessofv Creatingcardswithholesinthem(punchedcards)
v Sequencingthecardsintherightorder
u Eachcardisaninstruction tothemachinetodopreciselyonething(i.e.,putitselfintooneparticularstate)
u Asequenceofcards(i.e.,asequenceofinstructions)causesthemachinetostepthroughasequenceofstates.Thecardsequenceisaprogram
u Theweaverasaprogrammer37
JosephMarieJacquard(aswovenbyhisloomviaaprogramof24,000instructions).ImagecourtesyofWikipedia.
The Jacquard Loom: Programming
u Adiscrete,‘automatic’machineu Sincewehavechosenabinaryencodingthemachinestateisabinarynumber
u Eachinstruction isalsoabinarynumbersinceeachinstructionis(literally)thestatetheprogrammerwantsthemachinetobeinwhenthatinstructionisexecuted
u Theprogram forthemachineisasequenceofinstructions.Eachprogramis(literally)asequenceofstatestheprogrammerwantsthemachinetostepthrough
u Theprogram isthusasequenceofbinarynumbers38
A Loom Program
000000000010000010
001000100000101000
000010000
000101000001000100
010000010000000000
39
0130
6840
16
4068
1300
u Thismachine’sstateiscapturedina9-bitword
u Eachinstructionintheprogramisalsoa9-bitword
u Thestateandeachinstructionisthus9bitswide
u Thisprogramis9instructionslong
Loom Program Limitations
uDoesnotscale:v Largeinstructions:Toprograma‘big’machineyouneed‘big’words(largestateimplieslargeinstructionwidths)
v Nocounting:Norepeatsorloopstodothingsoveracertainnumberoftimes(No“do..while”or“repeat..until”)
v Nomodularity:Nologicalchunksforsub-patternsthatcanbereusedwithoutreplication(No“functions,methods,subroutines…”)
uNodecisionmakingonthefly:v Nobranchingtodecidetodoonethinginsteadofanotherbasedonacondition(No“if-then-else”.Nojumpsor“goto”)
u SoistheJacquardloomacomputer? 40
How Big/Fast is a Modern Computer?
u TypicalMacbook Prolaptophas~1billiontransistorsu Thestateofthemachineisabinarynumberwith~1billionbits(abinarywordofwidth~1billion)v NotpossibletoprogramaMacbook Probywritingasequenceofinstructionseach~1Billionbitswide
u AMacbook Proexecutes~5billioninstructionspersecondv Possible tohaveprogramsthatarebillionsofinstructionslongandyethavethemfinishoperatinginareasonabletime
41
Modern Computers?
u Ifmoderncomputersaresobig,howdoweprogramthem?u Wemodel(abstract)thecomputerassomethingmoresimple
u Programtothatmodel
u ThenletthehardwareandOSsortoutthedifferencebetweenrealityandourabstraction
u Thismethodofproblemsolvingisvery,verycommoninCS
u Morelaterinsemester
42
ìComputer HistoryMechanicalcomputers:Thedifferenceandanalyticalengines,theHollerithmachine
43
The Difference Engine (1822)
u CharlesBabbageuMechanicalcalculator tocomputemathematicaltables
v Loom:programtransformsthreadstopatternsonclothv Differenceengine:programtransformsnumbersintoothernumbers
u PolynomialfunctioncomputationusingdifferencesuOutputwasviaa‘printer’– adevicethatproducedprinter’splatessotheycouldbestampedontopaper
uNobranchingorlooping,limitedinwhatitcouldcompute
44
VideofromYouTube.
The Analytical Engine (1837)
u CharlesBabbageuWorld’sfirstgeneralpurpose mechanicalcalculator
v Memoryv Arithmeticunitv Branchingv Looping
u ProgrammedbypunchedcardslikealoomuOutputwasviaa‘printer’– adevicethatproducedprinter’splatessotheycouldbestampedontopaper
45
VideofromYouTube.
The Hollerith Tabulator (1890)u HermannHollerithu Firstdevicetoreaddata intoamachine:an
electromechanicalsystembasedonpunchedcardsu BuilttotabulatetheresultsofUScensusu Hollerith'scontributionstomoderncomputingare...
"incalculable”v Hedidnotstopathisoriginal1890tabulatingmachineandsorter,but
producedmanyotherinnovativenewmodels.Healsoinventedthefirstautomaticcard-feedmechanism,thefirstkeypunch,andtookwhatwasperhapsthefirststeptowardsprogrammingbyintroducingawiringpanelinhis1906Type ITabulator,allowingittododifferentjobswithouthavingtoberebuilt!(The1890Tabulatorwashardwiredtooperateonlyon1890Censuscards.)Theseinventionswerethefoundationofthemoderninformationprocessingindustry.
u HollerithwentontoformtheTabulatingMachineCompany.MergedwithotherstoformtheComputingTabulatingRecordingCompany(CTR).Renamedin1924toInternationalBusinessMachines(IBM)
46
HermannHollerithandoneofhispunchedcards.ImagescourtesyofWikipedia.
The ENIAC (1943-46)
u ElectronicNumericalIntegratorAndComputer
u EckertandMauchly (UniversityofPennsylvania)
u Firstelectronic,generalpurposecomputer.Turing-complete,digital,reprogrammable(cumbersome)
u Vacuumtubeanddiode-based
47
The EDVAC (1944-49)
u ElectronicDiscreteVariableAutomaticComputer(EckertandMauchly)
u Firststoredprogramcomputer,binary(ENIACwasdecimal).Operational1951.
u PopularizedbyvonNeumann(FirstDraftofaReportontheEDVAC)– firstreportonamoderncomputerarchitecture
48
Computer History Summary
49
u Althoughcomputerscan(andhavebeen)builtusingallkindsofhardware,moderncomputingreallytookoffwiththeinventionofelectroniccomputerswhichwereprecededbymechanicalcomputers
u AhistoryofcomputingandtheJacquardLoomuMechanicalComputers
v TheDifferenceandAnalyticalEnginesv TheHollerithMachine
u ElectronicComputersv FromEDSACtotheMacbook
Fundamental Concepts
uStateanddiscretemachinesuAbstractionandmodelsuEncodingdataandinstructionsuProgramminguTobegeneral,programsneedtoaccessamemory,andtobeabletocontroltheorderoftheinstructionstoexecutebasedontheresultsofcomputation
50
Review of terms
uState:Theconditionofasystematapointintime
uEncoding:Symbolicexpressionusedtorepresentinformation
uDiscrete:Proceedinginfinitesteps,individuallyseparateanddistinct
uBinary:Numericalnotationthatusesbase2uAbstraction:Simplified(“higher-level”)description 51
ìNext time: Computer ArchitectureHowarecomputersbuilt?
52