8 February How Computers Work Algorithms The Internet
8 February How Computers Work: Algorithms The Internet
News l Michelle
Simplified Model of a Computer retrieves the instruction directs data movement defines an algorithm Performs the operations processor Control Unit Arithmetic Logic Unit instructions data MEMORY the information that it works on
What is an algorithm? l l A detailed sequence of actions to perform to accomplish some task Named after an Iranian mathematician, Al. Khawarizmi l l l 813 – 833 C. E. Mathematician: algebra, trigonometry, geometry Astronomy and geography as well
Examples of Algorithms l Mapquest directions Assembly instructions User’s manual Software program l Other examples? l l l
A simple algorithm l Using a calculator, how do you find the average of three numbers? l l l Assume no average function Assume that the calculator is already on Solution Enter the first number; enter + Enter the second number; enter + Enter the third number; enter / 3 =
A bigger example l Using a calculator, how do you find the average of 100 numbers? l l l No longer want to list one by one Introduces loops Solution For each number, Enter the number; enter + Enter / 100 =
A more complex algorithm l l l Take the average of only the positive numbers Introduces decision making Solution If the number is greater than 0 Add the number Else Subtract 1 from the count of numbers
For the Computer to Execute an Algorithm l l Instructions must be very explicit Instructions must be in a form that the computer can understand l l l Operation operand Operation: what to do Operand: what to do it to Example: ADD 3, 5 Let’s look at programming a robot
Chef Robot Actually, there is a Chinese food chef robot
The Internet l What is it? l l The infrastructure that connects identified computers Links = the wires Routers = the boxes that connect them World Wide Web l l Computers that contain information to be shared Servers
How Do You Get to the Servers? Computers are connected through a network l Network requires protocol to work l l l A protocol is a set of rules The one that is used here is called IP (Internet Protocol)
How would you route a note? l l l Count off If I hand one of you a note for a set number, what do you need to know? Which way to go – not exactly where it is Your number, the number you want to get to Algorithm? If number is l l l greater, pass left smaller, pass right equal, read
How Networking Works l Computers need the same thing l l l Who identified by IP address l Every machine that is connected to the network has one l http: //www. lawrencegoetz. com/programs/ipinfo/ l Command prompt Routers know how to get there But IP addresses aren’t user friendly l l Give names instead Domain Name Server does the mapping
Anatomy of a URL l Protocol: server-name/file-to-display l Protocol: usually http l Have you ever seen others? https? Server-name l The computer’s name l l l Usually begins with www Usually ends with 3 characters that define the kind of site However, there are no rules: as long as its registered, you can get there File-to-display l Can be a whole path (just like Windows)
How to Build that File l Text file that says what to display l l l Two types of information l l l Web pages use HTML Hypertext Markup Language Text Instructions on how to display Instructions are in the form of tags l < command >
Why Should You Learn About HTML? l l l Mainly, to demystify But if you are building, you want to know even if you have a package to help you build Why? l l Sometimes you can’t figure out how to make it do what you want Sometimes you can’t figure out what is wrong Sometimes you just want to make some minor changes to an existing page If you understand how it works, YOU are in control and not the editor
General Structure: HTML Page <html> <! --- most important item in head is the title --- > <head> <meta content="text/html; charset=ISO-8859 -1" http-equiv="content-type"> <title></title> </head> <! --- body is where the “good stuff” is --- > <body> </body> </html>
Tuesday: We’ll Build a Page l Bring your laptop
- Slides: 19