1 / 17

LSP 121

LSP 121. Computers and Algorithmic Processes. What Is An Algorithmic Process?. An ordered series of steps that when applied to a problem produces a solution Some call it “thinking logically” Others refer to it simply as problem solving Often simply called an algorithm.

marcusmoore
Download Presentation

LSP 121

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LSP 121 Computers and Algorithmic Processes

  2. What Is An Algorithmic Process? • An ordered series of steps that when applied to a problem produces a solution • Some call it “thinking logically” • Others refer to it simply as problem solving • Often simply called an algorithm

  3. 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, daily living (buying a car or house, career changes, college choices) • Create useful short programs (called “macros”) in Access, Excel, and Word • E.g. Find all the grades for a student, remove the lowest homework grade, then calculate the average. • Write a simple program to analyze data and write the next article exposing cheaters in your school district (like Freakonomics)

  4. Computers and Algorithms • Computers are very good at executing algorithms • But computers require precise instructions to perform an operation • This is basically the definition of an algorithm. (A series of precise instructions to perform an operation.) • The instructions cannot be ambiguous (must be clear and concise) • Let’s try an example – Begin today’s activity

  5. 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 1 2. Conditional operations, e.g. If the mixture is too dry, then add ½ cup water; If the current account balance < 0, then account overdrawn The if-else statement from today’s activity is an example of a conditional.

  6. 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 +1 ‘Looping’ as seen in today’s activity is an example of an iterative operation. 4. Calling a pre-existing algorithm (or function), e.g. Make a reduction with your sauce; date := getDate();

  7. Algorithm to calculate Miles Per Gallon • Step 1: Get the values for gallons used, starting mileage, ending mileage • E.g. Ask the user to type in these values • Step 2: Set the value of distance driven to ending mileage – starting mileage • Step 3: Set the value of average miles per gallon to distance driven / gallons used • Step 4: Print the value of average miles per gallon • Step 5: Stop

  8. “Fancier” Average Miles Per Gallon • Step 1: Get values for gallons used, starting mileage, ending mileage • Step 2: Set the value of distance driven to ending mileage – starting mileage • Step 3: Set the value of average miles per gallon to distance driven / gallons used • Step 4: Print the value of average miles per gallon (continued on next slide)

  9. Modified Average Miles Per Gallon Continued • Step 5: If average miles per gallon is greater than 25.0 then • Print the message “You are getting good gas mileage!” Else • Print the message “You are NOT getting good gas mileage.” • Step 6: Stop

  10. If-Else: e.g. Algorithm: Inviting Friends to a Party This slide is a demonstration of PESUDOCODE It is similar to programming statements, but are more English-like than programming-like. • Step 1: For each of your friends do this loop: • Step 2: • Ifthis a close friend then • Write an invitation • Address an envelope • Stick on a stamp • Else • Put their name on the reserve list • Step 3: Check off their name • Repeat Steps 2 and 3 until no more friends • Step 4: Count number of guests (for food) • Step 5: Mail invitations • Step 6: Stop

  11. Let’s Try Another Example • Let’s try one together. Write an algorithm (in “pseudocode”) to examine student scores on an exam. You want to count how many students passed (>=70) and how many students failed (<70). When you hit the end of the list, print the total number of students that passed and the total number of students that failed. • Try next activity: Alice

  12. Well-Known / Common Algorithms • Sorting data • Searching for data • Routing a packet across the Internet • Finding an optimal solution to a problem (such as finding the best route on a map using GPS device or mapping web site)

  13. HTML • Hyper-Text Markup Language • All web pages are made (to varying degrees) from HTML • Relatively simple: no conditionals (if-else) or iterative statements (loops) • Each HTML command tells the web browser what to do next, such as start a new paragraph, display an image, or insert a hyperlink (clickable item)

  14. <html> Begins every HTML document <head> Begins the head section <title>DePaul University </title> Title that appears on browser title bar </head> Ends the head section <body> Begins the body section This is the first line.<br> Text followed by line Break <p>Start a new paragraph.</p> Begins a new paragraph <h1>First Heading</h1> Level 1 heading (biggest) <h2>A second level heading</h2> Level 2 heading (little smaller) <hr> Inserts a horizontal rule (straight line) <strong>This line is bold.</strong> Bold text <br> <em>This line is italicized</em> Italicized text <br> <img src=“\images\banner.gif”> Insert an image here <a href=“http://www.cs.depaul.edu”> DePaul CS Page</a> Link to another web page </body> Close the body section </html> Ends every HTML document

  15. Wanna learn how to create web pages? • CDM offers courses that teach you how: • IT-230: You also learn a little bit of programming • HCI-201: Uses FrontPage

  16. HTML • Let’s try creating a web page using HTML Activity – Creating an e-portfolio

  17. Last Activities • Let’s finish our algorithm topic with the following activities • Creating a Google Mash-up • VBA coin toss problem • If time permits – Google searching techniques

More Related