David Goldschmidt goldschd@strose.edu no office hours -- see me before or after class -- also send me email CSCI-1100 Computer Science I Where do we find computers today? Problem Solving What is a Computer? -- a device/tool for solving problem -- near-perfect data storage -- FAST! -- greater accuracy in calculations -- help humans focus on the "bigger problem" -- forecasting, prediction, "what if?" -- robotics -- no human aspect -- do "jobs" humans cannot (reduce risk) -- can put people out of work.... -- programmable / flexible -- on average, how many bugs/errors in 1000 lines of code? 15-50 -- on average, the percentage of code that handles error cases? 75%? Programming is nothing more than instructing the computer what to do -- how to solve a problem What's an Algorithm? -- a generalized process (e.g. how to make a sandwich) -- something that takes variable inputs and gives you some sort of output -- solves a problem Write me an algorithm to change a light bulb: (1) Make sure the light switch is off (2) If you can't reach the light bulb, get a ladder and put it under the light (3) If you got a ladder, climb the ladder (4) Unscrew the old bulb (5) Screw in the new bulb (5.5) Climb down the ladder (6) Turn it back on (to test it works!) Try again: INPUTS: new light bulb, ladder, light that doesn't turn on Writing algorithms: -- Understand the problem to be solved (ask questions -- refine requirements) -- Figure out how you might solve the problem (brainstorm solutions -- what additional tools do we need?) -- Develop an algorithm to solve the problem -- Write a program to instruct the computer as to how to solve the problem -- Test your program/solution -- make sure it works -- Repeat Write me an algorithm to get from RPI to Cape Cod: -- start with Lally 104 -- driving directions (1) Open Internet browser (2) Go to http://maps.google.com (3) Click on directions (4) Enter location of your car and Cape Cod (5) Click "get directions" (6) Print directions (7) Enter car (8) Gas up (or plug in your car) (9) Follow directions (7.5) Check engine lights -- if error, go to mechanic (1) Use GPS (1) Buy a paper map of US or globe (seatbelt the globe) (1) Start driving east (2) When you get to Boston, go right (3) When you see signs for Cape Cod, ask someone for directions program1.cpp ==> program1.obj or program1.o 3GHz --> 3G /s --> 3,000,000,000 instructions/sec peta-Hz 11011001 ==> 217 01010101 ==> 64 + 16 + 4 + 1 ==> 85 10100000 ==> 128 + 32 ==> 160 Even or odd? if the rightmost digit is 1, then odd What's the range of values in a single byte? 00000000 ==> 0 11111111 ==> 255 What about signed numbers? 10100000 TWO'S COMPLEMENT REPRESENTATION: 11011001 ==> -128 + 89 ==> -39 01010101 ==> 64 + 16 + 4 + 1 ==> 85 10100000 ==> -128 + 32 ==> -96 2-byte numbers: 10010011 00100001 ==> 32768 + 4096 + 512 + 256 + 32 + 1 ==> TWO'S COMPLEMENT: 10010011 00100001 ==> -32768 + 4096 + 512 + 256 + 32 + 1 ==> 1-byte two's complement: what's the range of possible? 10000000 ==> -128 01111111 ==> 64 + 32 + 16 + 8 + 4 + 2 + 1 ==> 127