Computer Basics/Algorithms

Slides:



Advertisements
Similar presentations
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Advertisements

1 The Information School of the University of Washington Nov 8fit review © 2006 University of Washington Midterm 2 Review INFO/CSE 100, Fall 2006.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
1. By the end of this lecture you should be able … To describe in general terms how computers function To describe the fetch-execute cycle To explain.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Chapter 9_1 Following Instructions: Principles of Computer Operation.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Fluency with Information Technology Katherine Deibel, Fluency in Information Technology 1 INFO100 and CSE100 Katherine Deibel.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Introduction CSE 410, Spring 2008 Computer Systems
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
1 Computer Basics How exactly does a computer work? © Lawrence Snyder, 2004.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Remember Back To The Lightbot.
Chapter 5 Computing Components Nell Dale John Lewis.
Chapter 5 Computing Components. 5-2 Chapter Goals List the components and their function in a von Neumann machine Describe the fetch-decode-execute cycle.
Computer Architecture And Organization UNIT-II General System Architecture.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
بسم الله الرحمن الرحيم MEMORY AND I/O.
CHAPTER 1 COMPUTER SCIENCE II. HISTORY OF COMPUTERS (1.1) Eniac- one of the worlds first computers Used more electricity than an entire city block of.
Introduction CSE 410, Spring 2005 Computer Systems
Computer Architecture Adapted from CS10051 originally by Professor: Johnnie Baker Computer Science Department Kent State University von Neuman model.
Chapter 2 content Basic organization of computer What is motherboard
Computer Architecture and Number Systems
CPU Lesson 2.
The Study of Computer Science Chapter 0
Computer Science II Chapter 1.
Basic Computer Organization and Design
What Computers Can and Cannot Do
Computer Organization and Architecture + Networks
What is a computer? Simply put, a computer is a sophisticated electronic calculating machine that: Accepts input information, Processes the information.
Control Unit Lecture 6.
UNIT 9 Computer architecture
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
CSE 410, Spring 2006 Computer Systems
What is a computer? Simply put, a computer is a sophisticated electronic calculating machine that: Accepts input information, Processes the information.
Chapter 7.2 Computer Architecture
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Computer Architecture
The Study of Computer Science Chapter 0
Introduction of microprocessor
Chapter 1: An Overview of Computers and Programming Languages
CS703 - Advanced Operating Systems
Microcomputer Architecture
C++ Programming: From Problem Analysis to Program Design
Review As binary, what is /20/2018
Announcement Tomorrow’s office hr: CANCELLED! Show work!!
Computer Basics/Algorithms
Chapter 1: Introduction to Computers and Programming
The Study of Computer Science
Computer Science I CSC 135.
INFO/CSE 100, Spring 2005 Fluency in Information Technology
INFO/CSE 100, Spring 2006 Fluency in Information Technology
Chapter 5: Computer Systems Organization
Announcement Function ppt: download again
Computer Architecture
The Study of Computer Science
Introduction to Computer Architecture
Introduction to Computer Systems
Computer components is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format. Computer The computer.
The Study of Computer Science Chapter 0
Chapter 4 The Von Neumann Model
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Computer Basics/Algorithms INFO/CSE 100, Spring 2006 Fluency in Information Technology http://www.cs.washington.edu/100 12/3/2018 fit100-10-algorithms

Readings and References Fluency with Information Technology Chapters 9, 10 12/3/2018 fit100-10-algorithms

Overview During this quarter, we're looking at the actual workings of computer systems Organized as “layers of abstraction” application programs higher level languages: Javascript, SQL, … operating system concepts bits, bytes, assembly language transistors, electrons, photons 12/3/2018 fit100-10-algorithms

Layers of Abstraction At any level of abstraction, there are elements at that level the building blocks for those elements Abstraction isolates a layer from changes in the layer below improves developer productivity by reducing detail needed to accomplish a task helps define a single architecture that can be implemented with more than one organization 12/3/2018 fit100-10-algorithms

Architecture & Organization Architecture (the logical definition) defines elements and interfaces between layers Instruction Set Architecture instructions, registers, addressing Organization (the physical implementation) components and connections how instructions are implemented in hardware many different organizations can implement a single architecture 12/3/2018 fit100-10-algorithms

Computer Architecture Specification of how to program a specific computer family what instructions are available? how are the instructions formatted into bits? how many registers and what is their function? how is memory addressed? Some examples architectures IBM 360, 370, … PowerPC 601, 603, G5, … Intel x86 286, 386, 486, Pentium, … MIPS R2000, R3000, R4000, R5000, ... The example architectures are generally named after their processor chips… 12/3/2018 fit100-10-algorithms

Computer Organization Processor Data path (ALU) manipulate the bits The control controls the manipulation Memory cache memory - smaller, higher speed main memory - larger, slower speed Input / Output interface to the rest of the world The physical organization… 12/3/2018 fit100-10-algorithms

A Typical Organization main memory processor processor/memory bus A bus is path for electrical signals… I/O bus hard disk floppy disk CDROM drive serial ports network interface 12/3/2018 fit100-10-algorithms

Anatomy of a Computer ALU Control Input Mouse Keyboard Scanner Processor ALU Control Input Mouse Keyboard Scanner Hard Disk Floppy Disk Monitor Printer Speakers Memory Output 12/3/2018 fit100-10-algorithms

Computers… Deterministically execute instructions “Deterministically” means that when a computer chooses the next instruction to perform it will make the choice the same way each time Given the program instructions and the current input, you can always predict exactly which instruction will be executed next and what it will do When the computer is faced with the same set of choices and the same inputs, it will always make the same choice choosing the next instruction! Computers are not creative, have no imagination, have no intuition. Computers have no free will and they are not random! 12/3/2018 fit100-10-algorithms

Fetch/Execute Cycle Computer = instruction execution engine The fetch/execute cycle is the process that executes instructions Instruction Fetch (IF) Instruction Decode (ID) Data Fetch (DF) Instruction Execution (EX) Result Return (RR) Go through each of the instructions… 12/3/2018 fit100-10-algorithms

Memory ... Programs and the data they operate on must be in the memory while they are running Memory locations memory addresses G 1 o 2 D 3 a 4 w 5 g 6 s 7 ! 8 ! 9 10 11 ... memory contents byte=8 bits 1 1 12/3/2018 fit100-10-algorithms

Control The Fetch/Execute cycle is hardwired into the computer’s control, i.e. it is the actual “engine” Depending on the Instruction Set Architecture, the instructions say things like Put in memory location 20 the contents of memory location 10 + contents of memory location 16 The instructions executed have the form ADDB 10, 16, 20 Add the bytes from memory address 10 and memory address 16 and store the result in memory address 20 The computer doesn’t know the value of memory addresses 10 and 16, until it retrieves the data, nor does it care. Referring to a value, by referencing the memory address is fundamental to a computer’s versatility. The contents of the memory addresses can change. 6 10 11 12 13 14 15 12 16 17 18 19 18 20 21 ... 12/3/2018 fit100-10-algorithms

ALU The Arithmetic/Logic Unit does the actual computation Depending on the Instruction Set Architecture, each type of data has its own separate instructions ADDB : add bytes ADDBU : add bytes unsigned ADDH : add half words ADDHU : add halves unsigned ADD : add words ADDU : add words unsigned ADDS : add short decimal numbers ADDD : add long decimal numbers Most computers have only about a 100-150 instructions hard wired 12/3/2018 fit100-10-algorithms

Input/Output Input units bring data to memory from outside world; output units send data to outside world from memory Most peripheral devices are “dumb”, meaning that the processor assists in their operation For example: when you type Shift-W on a keyboard, the keyboard doesn’t capitalize the letter… It sends both a shift and w keys to the computer and the processor turns it into a capital W. A device driver is the software that processes the input devices input. The CDs you get when you buy new hardware, come with a device driver. 12/3/2018 fit100-10-algorithms

The PC’s PC The program counter (PC) tells where the next instruction comes from In some architectures, instructions are always 4 bytes long, so add 4 to the PC to find the next instruction Program Counter: 112 Every PC has a PC! PC + 4 = the next instruction If there is no instruction the computers have a kind of idle loop to wait 112 113 114 115 116 117 118 119 120 121 ADD 210,216,220 AND 414,418,720 OR ... 12/3/2018 fit100-10-algorithms

Clocks Run The Engine The rate that a computer “spins around” the Fetch/Execute cycle is controlled by its clock Current clocks run 2-3 GHz The computer tries do at least one instruction per cycle, depending on the instruction and the availability of memory contents Modern processors often try to do more than one instruction per cycle Clock rate is not a good indicator of speed anymore, because several things are happening every clock cycle 12/3/2018 fit100-10-algorithms

Programming Converting the complicated tasks we want the computer to do into simple instructions Computers can be programmed to convert the complex into the simple Computers only understand binary digits Developers created assembly language as a convenient form for instructions For example; ADDD 2000, 8000, 4000 Translation from assembly to binary is called assembling High-level languages are used to complete more complex tasks easily Translation from a programming language to assembly is called compilation Examples of high-level programming languages are C, Smalltalk, C++, and Java. 12/3/2018 fit100-10-algorithms

Algorithm Algorithm a precise, systematic method to produce a desired result For example, the placeholder technique for deleting a short string except where it occurs in longer strings is an algorithm with an easy specification: longStringWithShortStringInIt  placeholder ShortString  e placeholder  longStringWithShortStringInIt Replace longStrings with a placeholder Delete all shortStrings Replace all placeholders with longStrings 12/3/2018 fit100-10-algorithms

Properties of an Algorithm For an algorithm to be well specified it must have … Inputs specified The range of possible inputs is well defined Outputs specified The desired output is well defined Definiteness The steps to take are definite and understandable Effectiveness The steps must be possible to accomplish Finiteness A processor that follows the algorithm will eventually finish 12/3/2018 fit100-10-algorithms

Communicating… People can fill in missing steps, but can get swamped by lots of details and clutter Computers cannot fill in missing steps, but can manage lots and lots of detail without error What helps when communicating with computers? Be organized and consistent in all the details Invent abstractions to help specify the basic ideas accurately and consistently Analyze your algorithm and its implementation, because you won’t get to interact later Communicating with people is not the same as communicating with computers! 12/3/2018 fit100-10-algorithms

Example: Directions to the Bookstore To another student To a robot Go past the library and walk up the Ave to the Bookstore Exit this room. Turn right. Proceed to elevator entrance hall. Turn right. Call elevator ... The student operates at a higher level of abstraction with a richer vocabulary of shorthands An algorithm is a plan for how to accomplish a task A program is an implementation of an algorithm Good algorithms (at any level of abstraction) require precision 12/3/2018 fit100-10-algorithms

Algorithm Analysis: What is it? What is an algorithm? A sequence of steps that accomplishes a task Many different algorithms may correctly solve a given task can it be implemented with available equipment? will it complete within this lifetime? will it require gigabytes of memory? 12/3/2018 fit100-10-algorithms

Algorithm Analysis: Why do it? Understand the mathematical fundamentals needed to analyze algorithms Learn how to compare the efficiency of different algorithms in terms of running time and memory usage Study a number of standard algorithms for data manipulation and learn to use them for solving new problems 12/3/2018 fit100-10-algorithms

Programs vs Algorithms A program is an algorithm specialized to a particular situation an Algorithm longStringWithShortStringInIt  placeholder ShortString  e placeholder  longStringWithShortStringInIt a Program that implements the Algorithm   # // replace double <newlines> with <#>   e // delete all single < newlines> #   // restore all double <newlines> 12/3/2018 fit100-10-algorithms

Programming as Communication When we write a program, we are communicating with the computer other people The computer reads our program as the set of instructions that it should perform It just needs to know how, not why Other people read our programs to understand how and why Programs that don't work (bugs) Program evolution - new features Performance improvement 12/3/2018 fit100-10-algorithms

An algorithm to alphabetize CDs define variable named Artist use Artist to refer to the name of the group that made a CD for all slots in the rack starting at one end call the current slot alpha for all the remaining slots in the rack call the next slot beta Exchange? If Artist of the CD in the beta slot is earlier in the alphabet than the Artist of the CD in the alpha slot, interchange the CDs next beta next alpha done 12/3/2018 fit100-10-algorithms

Another sorting demo… With plastic bottles! 12/3/2018 fit100-10-algorithms

Summary We can figure out many algorithms on our own, abstracting from specific cases We can learn from others who have studied particular algorithms in depth We abstract parts of an algorithm or program to understand them Thinking of how the program works and reasoning about its properties allows us to know why an algorithm works … and then we can get the computer to do it for us 12/3/2018 fit100-10-algorithms