Ah, mynameisDavidMalin, and I actuallytookthiscoursemyselfsophomoreyearsomeyearsago, butbut I almostdidn't Atthetime, I wasquiteuneasywiththeidea, frankly, oftaking a computersciencecourse, letalonethiscourse.
Andsomyfreshmanyear, atleast, I reallygravitatedtowardscoursesanddepartmentswithwhich I wasmuchmorefamiliar.
Computersciencewaswellbeyondmycomfortzoneatthetime, anditwasreallytheseunfamiliarwatersthat I wasn't quitereadytoshopevenmyfirstyear.
Butsophomoreyear, I finallygotupthenervetocome, likethroughthedoorofCS 50 andonLee, becausetheprofessoratthetimeletmetakethecoursepassfail.
I wasthatuneasy, andifonly I hadknownatthetimewhat I nowknow, whichis.
The 2/3 ofCS 50 studentshavenevertaken a computersciencecoursebefore, soifyouarefeelingsimilarlyuneasywiththeideaoftryingsomethingnew, orevenifyouhavepriorbackgroundbutarelookingtofillingapsinyourknowledge.
Soevenifyoujustgenerallyknewwhatbuyingthatbinderisspokenbycomputers, itjustmeansthat a computertorepresentthenumberweknowistosomehowstores a patternofsymbolsof 010 Howdotheyrepresentthree 011 forthesamereason?
SothechallengeaheadhereisCouldyougoaheadandrepresentforusinbinary, usingeachoftheselightbulbsandinturn, switches a zerosandonessaythenumber 50 theymightturnonelightbulbonrepresentingthe 30 two's placemightturn a light.
Boban, representingtheeightsplaceortotalcountnowis 32 plusnoteightplus 16 I think.
Whichisgoingtogiveus 32 plus 16 whichis 48.
Andsowegetnow a roundofapplauseifwecould, Priyanka, thanksverymuch.
Giveusjust a moment.
Soeachoftheselightbulbsthenrepresentsjust a switchorbitandinsideofyourcomputer.
Ifyou'veeverheardthephrasetransistor, a transistorisjust a tinylittleswitchandourcomputersthattheyhavemillionsorbillionsoftheseswitchesthattheyusephysicallytorepresentinformationinstorevalues, justlikePriyankadidhere.
Soif a computerweretorepresentthenumber 50 itwouldliterallyturnonthreeswitchesofsorts.
Store a littlebitofelectricityhere, hereandheretorepresentthenumber 50.
How, then, does a computerallowyoutosendtextmessagesand e mailsandcomposeddocumentsandsoforth?
Weneedtoallagreehowwe'regoingtogoaboutrepresentingcharactersorlettersofanalphabetpiot, Englishorsomethingelseinstead, andanyintuitionforhow, if a computeronlyhasmillionsorbillionsofswitchesthatcanbeturnedonandofftherebyrepresentingnumbers, wecouldpossiblygoaboutrepresentingsomethingotherthannumbersliketheletter A saganby a digit.
Sowemaybejustneedtoagree.
As a group.
Youknowwhat?
Let's allagreethattheletter A inthecontextof a wordprocessingprogramor a textmessageoremailjustneedstoberepresentedby a number, andweallneedtoagreewhatthatnumberis.
Somaybesupersimply, Let's justsay a isone B istoseeisthreeandsoforth, andyoucouldimaginethemhaving a computerturnonlotsoflittletransistorstorepresent A and B and C, solongasthesoftwareonthatcomputeraswellsee, knowsthatit's a wordprocessingprogramandnot, say, a calculatororsomethingthat's meanttousenumbersalone.
Soitturnsoutthatcomputersdon't actuallyusethenumberonefor a ortwo.
For B.
It's a littlebiggerthanthat.
TheworlddecideddecadesagothattheCapitalLetter A isgonnaberepresentedbythenumber 65 65 whichistosay, ifyouhave a biteofinformationinthecomputerandthisistheones, placetwosfor a 16 30 to 64.
If a computerweretostorethecapitalletter a usingeightbitsorswitches, itwouldjustturnonthosetothe 64thplaceandtheonesplace.
Andsowhenyouhaveactuallyreceived a messagein a textmessageoranemailwiththeCapitalLetter A.
Youhavejustreceived a patternofzerosandonessomehowwirelesslyorviawiresrepresentingthatpattern.
Specifically, thispatternhere, ifwedrawit, nothislightbulbs, butzerosandonesSoitturnsouttherearecertainlymorenumbersthanjust A's and B's and C's.
Wehavethewholealphabetpluspunctuation, thanksto a systemcalledAskingtheAmericanStandardCodeforInformationInterchange, whichisjust a fancywayofsayingthatthereis a welldefinedmapthathumansaroundtheworldagreedonyearsago.
Thatlooks a littlesomethinglikethis.
Sosay a 65 andIess 73 anddot, dot, dottobothends.
Sothatistosay, ifyouweretoreceive a messagefrom a computerorfrom a friendsaying 72 73 33 orthepatternofzerosandonesrepresentingthosedigits, Whatmessagedidyouperhapsjustreceive?
72?
73?
33 s sohigh?
So, quiteliterally, ifyouweretotext a friendhigh, theywouldreceive a messagethat's essentially a patternofzeroson 1 72 73 thensomething.
It's actuallynotobviousfromthechartwhattheyare, butitturnsout, 33 wasthenumberhumansgaveyearsagotorepresentsanexclamationpointinstead, andsoanyoftheotherpunctuationsymbolsyoumightseeonyourkeyboardsimilarly, havenumbersthat a computerwouldusethatallofusagreedonyearsagotorepresentthatvalue.
Butofcourse, thisis a veryAmericancentricatthemoment.
That's what's knownasUnicode, andthat's like a supersetofaskingbecauseaskingwaybackwhenusedonlyeightbits, whichisnotterriblymanytorepresentcharacters, Unicodeuseseightor 16 or 24 oreven 32 whichmeanswehavewaymanymorepossiblepatternsofzerosandoneswithwhichtorepresentthingslikethis.
Sothisisfacewithtearsofjoy.
Asof 2019.
ItisthemostpopularemojisentonIOSdevices, atleastdoesanyoneonce a hazard, a guessastowhatthedecimalnumberis.
Thatrepresents a facewithtearsofjoy, not 65.
It's not 72 not 73 800 higherthanthat 10,000 higherthanthat.
Soattheriskoftakingallofthefunoutofeversendingsomeoneemojiemojiwhenyousendthatfacewithtearsofjoy, you'reliterallyjustsomehowhavingyourphonesend a friend's phone.
Well, inthecontextofphotoshopor a browserorapplephotosorthelikeinthecontextof a graphicalprogram, yourcomputerisgonnainterpretthissamepatternofdigitsandinturnbitsnotashighexclamationpointbutassomeamountofred, someamountofgreen, someamountofblue.
Maybeit's a B, C, D e f or G orsomevariantthereof.
Maybehowlongyouholdthekeydownfour.
Andifyouhititreallyhard, maybehowlouditis.
Soyoucouldimagineusingthreevaluesthenotes, thedurationandthevolumejusttorepresentsomethinglike a pianosongmightbeoneencodingof a song, andthatmightusedifferentvaluesif I wanttoplayitevenlouderandlongeronsoforth.
Andthosenamesairhopefullysortedalphabeticallyfrom a through Z in a booklikethis.
Andeventhoughmostofusdon't reallyreachforthistechnologyanymore, considerthatit's reallythesameasyouriPhoneorAndroidphoneorotherdevice, whichhasallofyourcontactstoptobottom, andyoucanscrollthroughthemfrom a to Z, oryoucansearchforthembytypingintothelittleautocompletebox.
He's probablythiswaytowarddisease, because s, ofcourse, isbetweenthe M andthesea.
Soatthispoint, I canliterallyteartheprobleminhalf, throwhalfoftheproblemawayverydramaticallyandunnecessarilymakingthepointthatwe'venowgonefrom 1000 someoddpagestowhat 500 I coulddoitagain.
I went a littletoofarnowintheteasectionso I couldteartheprobleminhalfagain.
Throwthathalfaway, andnow I'm downtofrom 1000 2 500 to 250 pagesonLeeafterjusttwostepsinthisstepbystepprocess.
Andif I repeatthisagainandagainandagain, hopefully I'llbeleftultimatelywith, say, justonepageonwhichMikeSmitheitherisorisnot.
Soif I startwith, say, 1000 24 pagestotalinthephonebookand I'm lookingforMikeSmithand I divideandconquerthisproblem, spittingtheprobleminhalfinandhalfinandhalf I goto 5 12 I got 22 56 1 28 64 30 to 16 842 andone.
Afterjust 10 steps, I havefoundMikeSmith's page.
Bycontrast, thatfirstalgorithmwhere I justdidonepageat a time, howmanystepsmaybemighthavetakenmetofindMikeSmithlike 708 100 roughlywheretheessencemightbe.
Sointheworstcase, 1000 pages.
If I lookthroughthewholething, thesecondalgorithm, maybe 500 pages, because I'm goingtwiceat a time.
Whichistosaythat a lotofproblemsolvingreallyiswillfindisjustaboutharnessingyourexistingintuitionandcomfortwithideasthatnowyoujustneedtotranslateinsuch a waythatmachinesandotherhumanscanunderstand.
Well, considerthisfirstlinehereonthis y axisorverticalaxis.
Letmedescribethisisthetimetosolvesomeproblemsandonthehorizontalor X axisthesizeoftheproblem.
Sothenumberofpagesinthephonebookwouldgetbiggerasyougototheright, andthenumberofsecondsorpageturnsrequiredwouldgoupalongthe Y axishere, sothatfirstalgorithmdepictedhereinredsuggests, like a 1 to 1 relationshipbetweenthenumberofpagesinthebookandthenumberofsecondstofindsomeone.
Soyouhavethisstraightline a slopeof 1/1, ifyouwill.
Andsoifweconsiderthesecondalgorithm, thesecondalgorithmisalsogoingtobe a straightline.
Thisispseudocode, andthere's nooneformaldefinitionofthispseudocodeislikecodelikesyntaxthatyouwriteinEnglishoryourownspokenlanguagethatrepresentsyourideas, butin a succinctway.
Andso I mightproposethatthisalgorithmforfindingMikeSmithmightbewritteninpseudocodeEnglishLakesandTexasfollowsSteponepickupphonebook, whichwasindeedthefirstthing I didsteptoopentothemiddleofphonebook, whichisthenextthing I did.
Buttomakethosedecisions, youhavetoaskyourself a question.
Andthosequestionsandcomputersciencearecalledbooleanexpressionsafter a mathematiciannamedBulland a Booleanexpressionhighlightednowinyellowarejustquestionsthathaveyesornoanswersorifyouwill, trueorfalseanswersorheck, nowthatweknowbinaryoneorzeroanswer.
Soevenincode, wesee a hintoffwhyonesandzeroesarehelpful.
Lastly, there's thisthinghere.
Gobacktolinethreereviewsdidintwoplacesthatreferstosomethingwe'llcall a loop.
Butit's a programwrittenin a languagecalledSeeMauronthatnexttime.
Thatquitesimplysayshellototheworld, butitwouldn't doittodayinthecontextof a graphicallanguagefrom M.
I T.
MediaLabcalledScratch.
Thisis a languageviawhichyoucanprogram a computerbydragginganddroppingblocksorthingsthatlooklikepuzzlepiecesthatinterlocktogethersothatyoucantellthecomputerexactlywhattodo.
Whatscratchdot M I t dotvideo, which I'm abouttopullupmyself, isgoingtobewhereyouspendtimeinthefirstproblemset, andit's gonnalookquitelikethiswhenyouopenituponthelefthandsideofthiswebsite.
ThisWebbasedprogrammingenvironmentfrom M.
I t.
You'regoingtoseeonthelefthandside a wholebunchofpuzzlepieces, sotospeak, andthey'recategorizedaccordingtosomedifferentcolorsthereontheleftinthemiddle.
There's justgonnabe a bigwhitecanvasinitiallyontowhichyoucandraganddropthosepuzzlepiecesandlockthemtogethertomaketheprogramdosomething.
Andif I pokearound a littlefurtherundertheseblueblocks, forinstance, sensingthere's a bunchofpuzzlepiecesrelatedtoscratches, environmentsandoneofthoseisthisonehere, askwhat's yournameandwait, butthatWhat's yourname?
Expressionisin a whiteboxthat I canactuallychange.
Youcanaskanyquestionsyouwant, but I'llgoaheadandusethatdefault.
Butinsteadofthis, I wantedtosaymyname, butitwouldbeincorrecttojusttightmyname, becausethenmynameisalwaysgonnabeDavidnomatterwhoplaysthisgameorisaskedthequestion.
So I don't wanttodothat.
If I goinsteadtosensingandthendraganddropthispuzzlepiece, noticethis.
I mean, I toldthecomputerviathisalgorithmtodotoothtodothreethings.
Askwhat's yournameandwait.
Butthen I justsaysaidhellosayinganswerinsuchrapidsuccessionAndmyGod, artMacsandPCsandphonesthesedaysyou'resofast, they'regonnadosomanythingssoquicklythatitdidsayhello.
I'm notgonnaworryaboutseeingitforsomenumberofseconds, cause I'm onlygonnasayonethingnow, but I wassomehowwanttosay, hello, comma.
Andthentheuser's name.
Well, if I pokearoundfurtherandyouwouldonlyknowthisbyhavingseenitbefore, itturnsoutthere's thispuzzlepiecedownherecalledJoinandit's a littleweirdthatthedefaultwordsair, appleandbanana.
Butthoseairjustplaceholders.
If I goaheadanddragthisoverhere, itgrowstofillanditoverwriteswhatwasthere, I cansayHello, comma.
Andthen, lastlyinthatthirdexamplewherethingsgot a littlefancierandyouhad a startdragginganddroppinginnestingthesepuzzlepiecesnoticethatthisisthesameidea.
Theinputnowistwothings.
Helloandanswer.
Thosegointo a functioncalledJoin, theoutputofwhichshouldbeHello, commaDavid.
So, inthisway, evenwiththesimplestofpuzzlepieces, doesalleverythingfitintothissamemodelofproblemsolvingbutlet's nowmakethings a littlemoreinterestingratherthanjusttalkingtextwiththiscat's let's goaheadandhaven't dosomeotherthings.
Instead, letmegoaheadundersound, forinstance, anditlookslikethere's a blockinpinkhaircalledPlaysoundMiaountildone.
LetmegoaheadandintoourexamplesfrombeforeandgrabanotherexamplehereNow, instead, I'm goingtogobacktowhat's called a studioandscratchwherealloftheseexamplesthatcurrentlyare, and I'm gonnagoandopenup a examplecalledPETzeroComputerscientisttypicallystartcountingfromzerobecausethat's symbolicof, like, alloflightbulbsbeingoff.
Andsohere's a programnowthatif I hitplaydoesnotseemtodoanythingatonceatfirst, butnoticeas I movemycursorover.