LSP 121 COMPUTERS AND ALGORITHMIC PROCESSES What Is

  • Slides: 17
Download presentation
LSP 121 COMPUTERS AND ALGORITHMIC PROCESSES

LSP 121 COMPUTERS AND ALGORITHMIC PROCESSES

What Is An Algorithmic Process? An ordered series of steps that when applied to

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

Why Should We Know What An Algorithmic Process Is? Many things in life are

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)

Computers and Algorithms Computers are very good at executing algorithms But computers require precise

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

What is an Algorithm? Algorithms consist of four basic types of operations or instructions:

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.

What is an Algorithm? 3. Iterative operations, e. g. Repeat the previous two steps

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 : = get. Date();

Algorithm to calculate Miles Per Gallon Step 1: Get the values for gallons used,

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

“Fancier” Average Miles Per Gallon Step 1: Get values for gallons used, starting mileage,

“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)

Modified Average Miles Per Gallon Continued Step 5: If average miles per gallon is

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

If-Else: e. g. Algorithm: Inviting Friends to a Party Step 1: For each of

If-Else: e. g. Algorithm: Inviting Friends to a Party Step 1: For each of your friends do this loop: Step 2: If this 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 This slide is a demonstration of PESUDOCODE It is similar to programming statements, but are more English-like than programming-like.

Let’s Try Another Example Let’s try one together. Write an algorithm (in “pseudocode”) to

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

Well-Known / Common Algorithms Sorting data Searching for data Routing a packet across the

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)

HTML Hyper-Text Markup Language All web pages are made (to varying degrees) from HTML

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)

<html> <head> <title>De. Paul University </title> </head> Begins every HTML document Begins the head

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

Wanna learn how to create web pages? CDM offers courses that teach you how:

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 Front. Page

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

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

Last Activities Let’s finish our algorithm topic with the following activities Creating a Google

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