LSP 121 Computers and Algorithmic Processes. What Is A Processor?  All computers, cell phones, iPods, iPads, Kindles, automobiles, … have a processor.

  • Published on

  • View

  • Download


<ul><li><p>LSP 121Computers and Algorithmic Processes</p></li><li><p>What Is A Processor?All computers, cell phones, iPods, iPads, Kindles, automobiles, have a processor (or two or more) insideA processor accepts some kind of input, performs a computation, and produces some kind of outputFor example, one processor in an automobile inputs engine conditions and outputs fuel control </p></li><li><p>Multi-taskingMany processors can work on only ONE task at a time! (Dual-core/quad-core processors are exceptions to this rule)But they jump from one task to the next so quickly, it appears they are working on many tasks simultaneouslyWe say these processors can multi-taskCan you multi-task?</p></li><li><p>Multi-taskingNot too wellMany people can do two tasks at once, as long as one of the tasks doesnt require much cognitive thought (such as casual listening to music)But three or more tasks? Or tasks that require concentration? Sorry, you arent a computer. </p></li><li><p>Sometimes We ActLike ProcessorsLets say you work alone in a candy storeYou (the processor) wait on customers, ring up their orders, and answer the phoneOn slow days, you sit staring out the window, waiting for input (someone to enter the shop or for the phone to ring)(What happens on Valentines Day? You work REALLY fast or you hire another processor or the line goes out the door!)</p></li><li><p>A Sample ComputerLets examine your cell phoneWhat are the inputs?Buttons, touch screen, cell tower calling you, microphone, keypadWhat are the outputs?Speaker, screen, sending signal to cell tower</p></li><li><p>A Sample ComputerThe cell phone processor waits* until an input comes inWhen an input comes in, the processor processes something, then maybe produces an output (or maybe it just waits for more input)</p><p>* Some spin in a loop and some go to sleep</p></li><li><p>One Possible ScenarioThere are a number of functions running in a cellphoneOne function converts data into a signalAnother converts a signal into dataAnother accepts keystrokes on the keypadAnother accepts touches on the touch screen</p><p>(Weve seen other functions: PMT, NORMDIST, LOG)</p></li><li><p>REPEAT THE FOLLOWING STEPS </p><p>Is there data from the keypad? If yes, then process it.</p><p>Is there data from the touch screen? If yes, then process it.</p><p>Is there a signal coming in from a cell tower? If yes, </p><p>Is there data that has to go out to a cell tower? If yes, </p><p>Is there data that has to go out to the speaker? If yes, </p><p>Is there data coming in from the microphone? If yes, </p><p>UNTIL SHUT-OFF SEQUENCE IS CALLED</p><p>These steps form what we call an algorithmic process.</p></li><li><p>What Is An Algorithmic Process?An ordered series of steps that when applied to a problem produces a solutionSome call it thinking logicallyOthers refer to it simply as problem solvingOften simply called an algorithm</p></li><li><p>Why Should We Know What An Algorithmic Process Is?Many things in life are algorithmic processes:Music, dance (such as ballet), art, biology (natural selection, nature), math, economics, life (buying a car or house, career changes, grad school choice), workYou can create useful macros in Access, Excel, and WordYou can create iPhone apps and maybe make lots of money</p></li><li><p>Why Should We Know What An Algorithmic Process Is?You can write simple programs to analyze data and write the next article exposing cheaters in your school district (like Freakonomics)At work you can create financial models (business), reprogram digital synthesizers/ converters (music, cinema), design political districts (poly sci), weather prediction (earth sciences), create neural networks (psychology), model cultural evolution (sociology), diabetes management (medicine), create genetic algorithms (biology)</p></li><li><p>Computers and AlgorithmsComputers are very good at executing algorithmsBut computers require precise instructions to perform an operationThe instructions cannot be ambiguous (must be clear and concise)Lets see what this means: Lets do Activity 12</p></li><li><p>What is an Algorithm?Algorithms consist of four basic types of operations or instructions:1. Sequential operations, e.g. Add 1 cup of butter; Subtract the amount of the check from the current account balance; Set the value of x to 12. Conditional operations, e.g. If the mixture is too dry, then add cup water; If the current account balance &lt; 0, then transfer funds immediately</p></li><li><p>What is an Algorithm?3. Iterative operations, e.g. Repeat the previous two steps until the mixture has thickened; Repeat the following five steps until there are no more checks to be processed; Repeat steps 1,2 and 3 until the value of y is equal to +14. Calling a pre-existing algorithm (or function), e.g. Make a reduction with your sauce; date := getDate(); =normdist(x, mean, stdev, true)</p></li><li><p>ExampleAdd two values: 32542 + 42892How would you describe this operation to someone in grade school?</p></li><li><p>Average Miles Per GallonStep 1: Get values for gallons used, starting mileage, ending mileageStep 2: Set the value of distance driven to ending mileage starting mileageStep 3: Set the value of average miles per gallon to distance driven / gallons usedStep 4: Print the value of average miles per gallonStep 5: Stop</p></li><li><p>Modified Average Miles Per GallonStep 1: Get values for gallons used, starting mileage, ending mileageStep 2: Set the value of distance driven to ending mileage starting mileageStep 3: Set the value of average miles per gallon to distance driven / gallons usedStep 4: Print the value of average miles per gallon (continued on next slide)</p></li><li><p>Modified Average Miles Per Gallon ContinuedStep 5: If average miles per gallon is greater than 25.0 thenPrint the message You are getting good gas mileage!ElsePrint the message You are NOT getting good gas mileage. Buy a Chevy VoltStep 6: Stop</p></li><li><p>Inviting Friends to a PartyStep 1: For each of your friends do this loop:Step 2: If this a close friend thenPut them in the e-vite listElsePut their name on the B listStep 3: Check off their nameRepeat Steps 2 and 3 until no more friendsStep 4: Count number of guests (for food)Step 5: Mail invitationsStep 6: Stop</p></li><li><p>Next Quarters Class ScheduleI need a history class, an arts &amp; literature class, and a religious dimensions classI need to take the next two classes in my majorI dont want a class before 10:00amI definitely dont want a Saturday classIf I can get all my classes on Mon/Wed </p><p>This is NOT a trivial algorithm, yet you do this each quarter!</p></li><li>Lets Try Another ExampleLets try one together. Write the pseudocode to examine student scores on an exam. You want to count how many students passed (&gt;=70) and how many students failed (</li><li><p>Classic Applications of AlgorithmsSorting large data setsSearching for data (like Google)Routing a packet across the InternetFinding an optimal solution to a problem (such as finding the best route on a map using a GPS device or mapping web site)Detecting and correcting transmission errorsCompressing dataMaking data secure</p></li><li><p>AliceFor our next activity, lets use the programming system called AliceLook for the application Alice on your machine. (You can download Alice at home for free from the Skater Tutorial first, to get an idea of how Alice worksObserve the if statements and loop statements as you insert them into your codeDo Activity 13 - Alice</p></li><li><p>Visual BasicHere is an example of an If statement:if Row &lt; 100 thenCells(Row, 2) = 1elseCells(Row, 2) = 0end If</p></li><li><p>Visual BasicHere is an example of a while loop:Counter = 0while Counter &lt; 20 Counter = Counter + 1end while</p></li><li><p>Visual BasicHere is an example of a For loop</p><p>for Row = 1 To 50Y = rnd(a)X = X + Ynext RowYou can now try Activity 14</p></li><li><p>*</p><p>CompressionLossless versus LossyCompression is a technique used to squeeze data into a smaller spaceTwo basic groups of compression:Lossless when data is uncompressed, original data returnsLossy when data is uncompressed, you do not have the original data</p></li><li><p>*</p><p>Where is Compression Used?DVDs and Blu-Ray moviesBroadcast television and cable television signalsMusic players such as iPods and Nanos, as well as the music players within cell phonesTransferring large data files over the Internet</p></li><li><p>*</p><p>Lossless or Lossy?Compress a financial file? You want lossless (e.g. Lempel-Ziv)Compress a video image, movie, or audio file?Lossy is usually OK (e.g. MPEG, JPEG, MP3)Some people like their music uncompressed (e.g. FLAC, ALAC, Monkeys Audio)</p></li><li><p>*</p><p>Lossless CompressionRun-length encodingReplaces runs of 0s with a count of how many 0s.0000000000000010000000001100000000000000000000111000000000001 ^ (30 0s)</p><p>14 9 0 20 30 0 11</p></li><li><p>*</p><p>Run-length Encoding (continued)Now replace each decimal value with a 4-bit binary value (nibble)Note: If you need to code a value larger than 15, you need to use two consecutive 4-bit nibblesThe first is decimal 15, or binary 1111, and the second nibble is the remainderFor example, if the decimal value is 20, you would code 1111 0101 which is equivalent to 15 + 5</p></li><li><p>*</p><p>Run-length Encoding (continued)</p><p>If you want to code the value 15, you still need two nibbles: 1111 0000The rule is that if you ever have a nibble of 1111, you must follow it with another nibble</p></li><li><p>*</p><p>Lossy CompressionAudio and video dont compress well using run-length compressionAnd it is possible to trick the eyes and earsSo use lossy compression on video and music</p></li><li><p>*</p><p>Video CompressionIn one color video frame, not much is alikeBut what about from frame to frame?Send a frame, store it in a bufferNext frame is just difference from previous frameThen store that frame in buffer, etc.</p></li><li><p>*</p><p>5 7 6 2 8 6 6 3 5 66 5 7 5 5 6 3 2 4 78 4 6 8 5 6 4 8 8 55 1 2 9 8 6 5 5 6 6First Frame5 7 6 2 8 6 6 3 5 66 5 7 6 5 6 3 2 3 78 4 6 8 5 6 4 8 8 55 1 3 9 8 6 5 5 7 6Second Frame0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 -1 00 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0Difference</p><p>Lossy Compression (continued)</p></li><li><p>*</p><p>Lossy Compression (continued)What about a single image?JPEG (Joint Photographic Experts Group)Consists of 3 phases:Discrete cosine transformations (DCT)QuantizationRun-length encoding</p></li><li><p>Data Encryption/SecurityGo ahead and do Activity 15</p></li><li><p>Data ErrorsGo ahead and do Activity 16</p><p>********Actually, signals to and from a cell tower are handled by a separate signal processor within the phone.*************************</p></li></ul>


View more >