Download - MA/CS 109 Homework One Solutionsnyder/cs109/hw01.solution.fall17.pdf · MA/CS 109 Homework One Solution Problem 1 Give the decimal for the following binary numbers: a) 11011 = 16

Transcript

MA/CS109HomeworkOneSolutionProblem1Givethedecimalforthefollowingbinarynumbers:

a) 11011 =16+8+2+1=27b) 1111 =8+4+2+1=15c) 1001001 =64+8+1=73

Problem2Givethebinarynumbersforthefollowingdecimalnumbers:

a) 23 =16+4+2+1=10111b) 128 =10000000c) 72 =64+8=1001000

Problem3Addthefollowingtwobinarynumbers:

a) 101101+010111=1000100(check:45+23=68)b) 101010+111=110001(check:42+7=49)c) 111111111+1=1000000000(check:511+1=512)

Problem4Whatisthelargestnumberthatcanberepresentedin4bits?HowaboutinNbits,whereNisanarbitrarynumber(comeupwithageneralmathematicalformula)?4bitscanrepresent24=16possibilities,0–15,sothelargestnumberis1111=15.IngeneralthelargestnumberrepresentableinNbitsis2N–1.ThisisjustasequenceofN1s.Wehavestudiedinclassthevariousunitsforcomputerstorage.Answerthefollowingquestionsaboutthecorrespondencebetweentypicalamountsofinformationproducedbyhumansandcomputermemories.Youshouldusewww.wolframalpha.comtodothecalculations:itcanevaluateverylargenumbers.Forexponentsusethenotation“10^4”for“104”anduseasterisk“*”formultiplication.Roundtothenearestintegerforsmallishnumbersandusescientificnotationforlargenumbers.

Forexample,hereishowyouwouldfindhowmanycopiesoftheU.S.Constitution(withAmendments)youcanstoreonaCD(ithas50,534characterstotal):

So your answer would be 15,293. Problem5Thereareabout3,566,480charactersintheBibleand320,015intheKoran.AstandardCDcanholdabout737MB(MB=220bytes)ofdata.Incomparison,asingle-layerDVD-ROMcanhold4.7GB(GB=230bytes)ofdata.a)HowmanycopiesoftheBiblecouldyoustoreonatypicalCD,assumingonebyteforeachcharacter?(737*2^20)/3566480=216.b)HowmanycopiesoftheKorancouldyoustoreonatypicalCD,assumingtwobytesforeachcharacter(sincestoringArabiclettersmustbedoneinUnicode)?(737*2^20)/(2*320015)=1207.44 Problem6CurrentlyyoucanbuyonAmazonaSeagate8TB(TB=240)externaldiskdriveforyourMaconfor$199.99.

(a)TheLibraryofCongressstoresabout3x1015bytesofdata.HowmuchwoulditcosttostorethewholeoftheLibraryofCongressonthesedisks?(Roundtothenearestpenny!)$199.99*(3*10^15)/(8*2^40)=$68,208.69.(b)HumanDNAholdsabout725MBofdata,andthereare7.6billionpeopleonEarth.HowmuchwoulditcosttostoreallthedatainhumanDNAontheplanetonSeagateexternaldisks?Thatwouldbe725*2^20*7.6*10^9bytestostore.Soitwouldcost$199.99*(725*2^20*7.6*10^9)/(8*2^40)=$131,362,068.65(oktoapproximate)Problem7Ifyouareasophomore,youwillgraduateBU(hopefully)in2020,atwhichpointitispredictedthattherewillbe44x1021bytesofdatastoredonthisplanet.(a)Asheetofbookpaperisabout0.1millimeters(10-4meters)thick.Ifallthedataintheworldin2020wereprintedonpaperandstackedup,andassumingabout3000characterseachside(twosided)ofapage,andtwobytesperword(inUnicode,andforgetaboutimagesandsounds,justpretenditisalltext),andassumingthesolarsystem(endingatNeptune)hasadiameterof9.09billionkilometers,howmanytimeslargerwouldthisstackofpaperbethanthediameterofthesolarsystem?Eachtwosidedpagecanstore3000characters*2sides*2bytes=12,000bytes,soeachmeterinthestackcanstore12000*10,000=120,000,000bytes.Thus,thestackwouldbe(44*10^21/120000000)metershigh,sotheansweris:(44*10^21/120000000)/(9.09*10^12)=40.33.b)TheSeagatediskdrivementionedabovehasdimensions4.65” x 1.61” x 7.8”, so it is 1.61” wide. If you stored all the data in 2020 in such drives, and lined them up side to side (each taking up 1.61 inches), how many times around the circumference of the earth (24,901miles,with5280feetpermile)would they go? (1.61*44*10^21/(8*2^40))/(24901*5280*12)=5.1times

c)AgramofDNAcanhold215x1015bytesofdata.HowmanykilogramsofDNAwouldittaketostorealltheinformationontheplanetin2020?Wouldyoubeabletoliftit?DNAcanhold215x1015x103=2.15x1020bytesofdataperkilogram.Soitwouldtake44x1021/(2.15x1020)=204KGofDNA.Thisisabout450pounds,sono,youcouldn’tlifeitunlessyouareanOlympicweightlifter!Problem8What would be the minimum bit depth (total number of bits) necessary to represent 512 colors? How about to represent 179 colors? Since 29 = 512, then 9 bits would be necessary. We have 27 = 128 and 28 = 256, so you would need 8 bits for 179 colors (with some possibilities unused). Problem9 If you use 4 bits per color component and three components (red/green/blue), how many different colors can you represent? There would be 3*4 = 12 total bit depth with three colors, so 212 = 4096 colors could be represented. Problem10 If a typical audio CD uses a sample rate of 44.1 KHz (KHz = 1000 / second) and stores each sample in 16 bits, how many hours and minutes of audio can be stored on a typical audio CD? Give your answer in whole number of hours and minutes (e.g. “1 hour and 34 minutes”). 16 bits is 2 bytes, so each second takes 44100 * 2 = 88200 bytes, so a CD could hold 737*2^20/88200 = 8,762 seconds of music, which is 2 hours and 26 minutes (and 2 seconds, which we can ignore).