Title: By the end of this lecture you should be able
1(No Transcript)
2By 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 what an algorithm is
- To describe the basic properties of algorithms
3Computers and Algorithms
Contents
How do computers work? Turing Machines
Von Neumann architecture Fetch-execute
cycle What is an algorithm?
4Computers and Algorithms
Contents
How do computers work? Turing Machines
Von Neumann architecture Fetch execute
cycle What is an algorithm?
5Historical perspectives Turing's machine
- Alan Turing developed the abstract notion of a
"Turing machine" - NOT a physical machine, but a mathematical model
of one type of very simple abstract calculating
device - He proved that there were Turing machines
(Universal machines) that were capable of
calculating anything and everything that any
Turing machine could calculate (given enough time
and enough memory)
6The upshot of this result of Turing's
- Very simple devices can be designed that are as
powerful computers as can be (if we don't have to
worry about how much time it will take or how
much memory is involved) - The practical lesson make things that have
larger and more efficient memory and faster
speeds and we can do anything that a computer can
do
7Computers and Algorithms
Contents
How do computers work? Turing Machines
Von Neumann architecture Fetch execute
cycle What is an algorithm?
8Historical perspectives von Neumann's
architecture
- Von Neumann added in a number of ideas that made
digital computing practical and his ideas remain
those of most digital programming to this day - Key among those ideas
- Programmes themselves are really just like any
other piece of data (0s and 1s) at least from
the standpoint of the computer
9Von Neumann architecture (simplified)
Memory
Control Unit
ArithmeticLogicUnit
10Von Neumann architecture
Memory
Stores the program and the data It has specific
and discrete locations each (generally) 1
byte Each location has a specific address These
addresses store values The total size of memory
locations is limited
11Diagram of computer memory-
Each memory location is one byte size
01010101 00101010 00111010 11101001
12Von Neumann architecture (simplified)
Memory
The Control Unit Executes instructions
Control Unit
ArithmeticLogicUnit
13Von Neumann architecture (simplified)
Memory
The ALU Does the logic and maths
Control Unit
ArithmeticLogicUnit
14Devices for both input and output
Memory
Control Unit
ArithmeticLogicUnit
Hard diskFloppy disk
15Input devices
Memory
Control Unit
ArithmeticLogicUnit
Mouse KeyboardScanner
16Output devices
Memory
Control Unit
ArithmeticLogicUnit
Monitor Printer Speakers
17Computers on the outside Input / output
Slightly out-of-date back of computer
http//facweb.northseattle.edu/tfiegenb/EET131/GX1
50User/about.htmAccessed 17-11-08
18RAM
19Basic computer commands
- Extremely limited set (nothing like the range of
commands that we give to computers) - Designed to be simple, easy to execute but can
be built up to do things that we want computers
to do (like spell-checks)
The power of a computer does not arise from
complexity. Instead, the computer has the ability
to perform simple operations at an extremely high
rate of speed. These operations can be combined
to provide the computer capabilities that you are
familiar with. The Architecture of Computer
Hardware and Systems Software. By Irv Englander
20Computers and Algorithms
Contents
How do computers work? Turing Machines
Von Neumann architecture Fetch execute
cycle What is an algorithm?
21The fetch/execute cycle.
22Illustration of a single ADD 2000 2080 4000
instruction
Results depend on the contents of the memory
locations referenced in the instruction.
23Computer before executing an ADD instruction.
24The Program counter
- This keeps track of what step needs to be
executed next. It uses the address of the next
instruction as its way of keeping track. This is
called the program counter. (Here 'PC') - Some instructions change the Program counter
(branch and jump instructions)
25Computer before executing an ADD instruction -
again
26Instruction Fetch Move instruction from memory
to the control unit.
27Instruction Decode Pull apart the instruction,
set up the operation in the ALU, and compute the
source and destination operand addresses.
28Data Fetch Move the operands from memory to the
ALU.
29Execute Compute the result of the operation in
the ALU.
30Result Return Store the result from the ALU
into the memory at the destination address.
31Algorithms
Contents
How do Computers Work? What is an
algorithm?Example
32What is an algorithm?
- An algorithm is an ordered set of unambiguous,
executable steps that defines a terminating
process
Brookshear Computer Science - A step-by-step procedure for solving a problem
- http//images.rbs.org/appendic
es/d_glossary_geometric.shtml - A finite set of well-defined rules for the
solution of a problem in a finite number of
steps. -
http//www.sabc.co.za/manual/ibm/9agloss.htm
33Algorithms for people
- People will think things through
- A general description may be enough
- Nonetheless, it is important to avoid ambiguity
and not to make too many assumptions
34Everyday examples of algorithm-like procedures
- Recipes
- Flat-pack assembly instructions (sometimes
sometimes not) - Directions
- Instructions on vending machines
35Five properties of algorithms
- Input-specified
- Output-specified
- Definiteness
- Effectiveness
- Finiteness
Fluency with IT by Lawrence Snyder
36Specifying the input and output
- Input what is going to be changed, used,
transformed by the process - Output the data that carries the results at the
end of the process - What type (of data, of )
- How much
37Definiteness
- Each step explicitly specified each step in a
specified order (so that at any stage it is
possible to determine what the next step is - May apply in different ways to different sorts of
problems
38From the River go to the Street and turn right
- Approaching a street from different directions,
resulting in the instruction turn right having
different meanings.
39Effectiveness
- Can be executed without additional input,
information from or us or oracles or psychics,
...
40Finiteness
- Comes to an end it stops
- (specify when to stop a repetition
- Long division
- 3.3
- 3) 10.0
- 9
- 1.0
- 9
41Algorithms
Contents
How do Computers Work? What is an
algorithm?Example
42Alphabetise and file your company's
correspondence
- Input A stack of folders. Each folder contains a
letter to your company. At the moment, there is
no order to the folders. - Output The same folders in the stack, but in
alphabetical order
This is an example of sorting Sorting is a very
common algorithmic process for computers. (Here
we have alphabetical sorting for example. With
any of these, the efficiency of the process is
important, but that's for later for now ...)
43Your problem -
- In groups, devise an algorithm for sorting CDs
into alphabetical order. - What operations can you do? (For us, what verbs
For machines what procedures or methods) - What does alphabetical order mean?
44Exam questions from 2009
- Describe the fetch execute cycle. 4 marks
- Draw a flow diagram or write in pseudo-code an
algorithm for alphabetising a collection of CDs.
4 marks
45(No Transcript)