Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 -...

50
Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview EDITION 7 / 8 J. Glenn Brookshear

Transcript of Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 -...

Page 1: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-1 Copyright © 2003 Pearson Education, Inc.

Figure:

Overzicht Informatica

College 1 - September 5 (Docent: Frank Seinstra)

Computer Sciencean overview

EDITION 7 / 8J. Glenn Brookshear

Page 2: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-2 Copyright © 2003 Pearson Education, Inc.

Overzicht Informatica:Huishoudelijke Mededelingen (1)

• Web:– http://www.science.uva.nl/~fjseins/– click op ‘Teaching’

• UvA Blackboard:– http://blackboard.ic.uva.nl/

• Email:– [email protected]

Page 3: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-3 Copyright © 2003 Pearson Education, Inc.

Overzicht Informatica:Huishoudelijke Mededelingen (2)

• College woensdag 7 september a.s.:– vervalt!

• College maandag 19 september:– vervanging Jan-Mark Geusebroek (o.a. AI, etc.)

• Let op (!) :– college-zalen steeds verschillend

Page 4: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-4 Copyright © 2003 Pearson Education, Inc.

Overzicht Informatica:Huishoudelijke Mededelingen (3)

• Vrijblijvend: schrijf-opdracht (max. 1.5 pnt):• “informatica in medische praktijk / onderzoek”

• Voorbeelden:– Surveillance-camera’s in ziekenhuis

• Wat is typisch voor medische sector?

• Automatische herkenningstechnieken?

– NOS Journaal, 2 September j.l.• Patientgegevens toegankelijk voor hackers…

– Tsunami December 2004• Computergestuurde technieken RIT?

Page 5: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-5 Copyright © 2003 Pearson Education, Inc.

Introduction:Computer Science - What is it? (1)

• A combination of many things...– includes a.o.:

• (1) hardware design, (2) programming, (3) human computer interaction, (4) artificial intelligence, etc...

– in other words:• mathematics, engineering, psychology, linguistics,

biology, business administration, ethics, sociology, …

• Certainly not:– ‘science’ of computer applications– ‘science’ of programming in language ‘X’

Page 6: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-6 Copyright © 2003 Pearson Education, Inc.

Introduction:Computer Science - What is it? (2)

• Science of algorithms:– algorithm (informally):

• set of steps that defines how a task is performed

• compare: ‘recipe’

– machine-compatible representation = ‘program’

Page 7: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-7 Copyright © 2003 Pearson Education, Inc.

Algorithmen zijn overal:

• Denk aan de reeks stappen die je uitvoert als je een CD in een CD speler afspeelt

Page 8: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-8 Copyright © 2003 Pearson Education, Inc.

The central role of algorithms in computer science

Page 9: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-9 Copyright © 2003 Pearson Education, Inc.

Introduction:Computer Science - What is it? (3)

• Science of ‘abstraction’:– obtaining external properties of an entity, by

hiding its internal details.

Page 10: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-10 Copyright © 2003 Pearson Education, Inc.

Introduction:Computer Science - What is it? (4)

• Abstraction... on abstraction... on...

Page 11: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-11 Copyright © 2003 Pearson Education, Inc.

Central issues identical in the past...

- Abacus (ca. 50 BC)

- Difference Engine (Babbage, ca. 1822)

- ENIAC (Univ. of Pennsylvania, 1945)

Page 12: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-12 Copyright © 2003 Pearson Education, Inc.

… today ...

- Distributed ASCI Supercomputer 2 (Vrije Universiteit, Amsterdam, 2002) (contains 72 1-Ghz Dual Pentium-IIIs)

- Earth Simulator (ES Center, Yokohama, Japan, 2001) (contains 5120 0.5-Ghz NEC CPUs)

Page 13: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-13 Copyright © 2003 Pearson Education, Inc.

… and in the future!

• World Wide Computing

Page 14: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-14 Copyright © 2003 Pearson Education, Inc.

C H A P T E R 1

Data Storage & Representation

Page 15: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-15 Copyright © 2003 Pearson Education, Inc.

Bits and Their Storage

• Information represented as patterns of bits (binary digits)

• A bit is either 0 or 1 (true or false)

• Meaning of bit(-stream)s varies• numeric values, characters, images, sounds…

• Requires a device that can be in one of two states (& remain in that state as long as needed)

• Flip-flop circuits

Page 16: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-16 Copyright © 2003 Pearson Education, Inc.

The Boolean Operations AND, OR, and XOR

• Note: AND and OR exist in natural language!

Page 17: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-17 Copyright © 2003 Pearson Education, Inc.

AND and OR Gates

Page 18: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-18 Copyright © 2003 Pearson Education, Inc.

XOR and NOT Gates

Page 19: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-19 Copyright © 2003 Pearson Education, Inc.

A Simple Flip-flop Circuit

• As long as both inputs remain 0: output does not change• Temporarily placing 1 on upper input => output = 1• Temporarily placing 1 on lower input => output = 0• So: output flip-flops between 2 values under external control

Page 20: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-20 Copyright © 2003 Pearson Education, Inc.

Setting the Output of a Flip-flop to 1

Page 21: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-21 Copyright © 2003 Pearson Education, Inc.

Setting the Output of a Flip-flop to 1 (cont’d)

Page 22: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-22 Copyright © 2003 Pearson Education, Inc.

Setting the Output of a Flip-flop to 1 (cont’d)

Page 23: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-23 Copyright © 2003 Pearson Education, Inc.

Opdracht:

• Bedenk hoe deze flip-flop de output-waarde 1 kan bewaren, en weer kan wissen:

Page 24: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-24 Copyright © 2003 Pearson Education, Inc.

Main Memory

• Large collection of circuits, each capable of storing a single bit

• Arranged in small cells, typically of 8 bits each (a.k.a.: byte)

Page 25: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-25 Copyright © 2003 Pearson Education, Inc.

Arrangement of Memory Cells

• Each cell has a unique address

address = 2 = 0x02

value = 01101101

• Longer strings stored by using consecutive cells

• RAM (random access memory)

Page 26: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-26 Copyright © 2003 Pearson Education, Inc.

Representing Information as Bit Patterns

• Now that we know how to store single bits, we can consider how information can be encoded as bit patterns

• Different encoding systems exist for different types of information– numbers, text, images, sound, …

• Encoding systems more and more standardized– American National Standards Institute (ANSI)– International Organization for Standardization (ISO)

Page 27: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-27 Copyright © 2003 Pearson Education, Inc.

Representing Text

• Each symbol represented by a unique bit pattern

• Text represented by long stream of patterns

• Today’s standard coding system:– ASCII (American Standard Code for Information Interchange)– Bit patterns of length 7 (generally extended by 1 bit)– See ASCII-table in Appendix A.

Page 28: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-28 Copyright © 2003 Pearson Education, Inc.

Representing Numbers

• ASCII-encoding inefficient for numeric values• Consider storing the value 25:

– In ASCII: 00110010 00110101 (16 bits)– Worse: largest 16-bit number would be 99

• More efficient approach is to use binary system– uses digits 0 and 1, incl. factor 2 for all bit-positions

• Compare decimal system– uses digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, incl. factor

10 for each decimal position

Page 29: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-29 Copyright © 2003 Pearson Education, Inc.

The Decimal and Binary Systems

• Many number-systems can be created this way!

Page 30: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-30 Copyright © 2003 Pearson Education, Inc.

Decoding the Binary Representation 100101

0

– 1×25 + 0×24 + 0×23 + 1×22 + 0×21 + 1×20 = 37

Page 31: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-31 Copyright © 2003 Pearson Education, Inc.

Obtaining the binary representation of 13

Page 32: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-32 Copyright © 2003 Pearson Education, Inc.

The Binary System: Addition

• Knowing how numeric values are encoded, we can consider how to do calculations

• Binary addition:

• Example: 0 0 1 1 1 0 1 0+ 0 0 0 1 1 0 1 1

10101010(58 + 27 = 85)

Page 33: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-33 Copyright © 2003 Pearson Education, Inc.

Fractions in the Binary System

• Radix point has same role as in decimal system

Page 34: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-34 Copyright © 2003 Pearson Education, Inc.

Storing Integers: Two’s Complement Notation

• In general: values of 32 bits

• Includes negative numbers

• Leftmost bit indicates the sign– sign bit

• Note:– Positive and negative numbers are

identical from right to left up to & including first ‘1’; from there on are complements of one another

Page 35: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-35 Copyright © 2003 Pearson Education, Inc.

Addition in two’s complement notation

• Note: no circuitry for subtraction needed!

• Note: overflow errors: 0101 + 0100 = 1001 (5 + 4 = -7)

Page 36: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-36 Copyright © 2003 Pearson Education, Inc.

The Hexadecimal Coding System

• Bit-streams often very long

• For simplicity of notation:– Hexadecimal system

• Reduces 4 bits to 1 symbol• Especially important in

assembly language programming (next chapter)

Page 37: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-37 Copyright © 2003 Pearson Education, Inc.

Opdracht - Chapter 1: Problem 6

How many cells can be in a computer’s main memory if each cell’s address can be represented by 3 hexadecimal digits?

• Three digits:– 3 positions, each of which can be one of 16 values

(from the range: 0, 1, …, 9, A, B, C, D, E, F)

– smallest: 000 = 0×162 + 0×161 + 0×160 = 0– largest: FFF = 15×162 + 15×161 + 15×160 = 4095

– So, total number of unique addresses = 163 = 4096

Page 38: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-38 Copyright © 2003 Pearson Education, Inc.

Opdracht - Chapter 1: Problem 23

Here's a message in ASCII. What does it say?

01010111 01101000 01100001 01110100 00100000 01100100 01101111 01100101 01110011 00100000 01101001 01110100 00100000 01110011 00110001 01111001 00111111

• Each block of 8 bits represents one character: – See ASCII table in Appendix A– Example: 01010111 = ‘W’– Message says: ‘What does it s1y?’– Note: 00110001 = ‘1’, while 01100001 = ‘a’…

Page 39: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-39 Copyright © 2003 Pearson Education, Inc.

Opdracht - Chapter 1: Problem 28

a. Write the number 14 by representing the 1 and 4 in ASCII.

b. Write the number 14 in binary representation.

• a. See ASCII Table in Appendix A:– 14 = 00110001 00110100

• b. In binary system each ‘1’ represents a power of 2:– 14 = 8 + 4 + 2 = 1×23 + 1×22 + 1×21 + 0×20 => binary: 1110

Page 40: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-40 Copyright © 2003 Pearson Education, Inc.

Storing Fractions: Floating-point Notation

• In contrast to integers, fractions require storage of the radix point– Floating-point notation

• Example: 1 110 1011 = -10.11 = -2.75

Page 41: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-41 Copyright © 2003 Pearson Education, Inc.

Truncation Errors: Coding the value 2 5/8

Page 42: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-42 Copyright © 2003 Pearson Education, Inc.

Truncation Errors (cont’d)

• Significance of truncation errors reduced by using larger mantissa & exponent fields (32bits)

• Problem of nonterminating expansion (e.g. 1/3)– worse in binary than in decimal system (e.g. 1/10)

• Interesting:– 2 1/2 + 1/8 + 1/8 = 2 1/2

– 1/8 + 1/8 + 2 1/2 = 2 3/4

• When adding numbers, order may be important– rule: add smaller values first!

Page 43: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-43 Copyright © 2003 Pearson Education, Inc.

Opdracht:

• Wat klopt hier niet?

Page 44: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-44 Copyright © 2003 Pearson Education, Inc.

Mass Storage

• Main memory is volatile and limited in size

• Additional memory devices for mass storage:– a.o.: magnetic disks, optical disks, magnetic tapes

• Advantages over main memory:– less volatile, large capacity, capability of removal,

generally much cheaper

• Disadvantages over main memory– mechanical motion for data access/retrieval (slow!)– in general: lesser degree of random access

Page 45: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-45 Copyright © 2003 Pearson Education, Inc.

A Magnetic Disk Storage System

• Each track contains same number of sectors • Location of tracks and sectors not permanent (formatting)• Examples: hard disks, floppy disks, Zip disks, ...

Page 46: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-46 Copyright © 2003 Pearson Education, Inc.

CD/DVD Storage Format

• Data stored by creating variations in the reflective surface• Data retrieved by means of a laser beam• Data stored uniformly (so CD rotation speed varies)• Random access much slower than for magnetic disks

Page 47: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-47 Copyright © 2003 Pearson Education, Inc.

Old, but still commonly used: Magnetic Tape

• Offers little or no random access (slooooooooooooooow!)• Good choice for off-line data storage (archives)

Page 48: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-48 Copyright © 2003 Pearson Education, Inc.

Conclusion

• Main memory, magnetic disks, compact disks, and magnetic tape exhibit decreasing degrees of random access to individual bytes of data!

Page 49: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-49 Copyright © 2003 Pearson Education, Inc.

Chapter 1: Conclusions

• Information stored as streams of bits

• Bit streams stored in main memory or on mass storage devices - each with different degree of random access (and thus: speed)

• Meaning of bit streams application dependent

• Standardized representations exist for (a.o):– text, numeric values, images, sounds, …

• For numeric values: overflow and truncation errors may make life difficult sometimes...

Page 50: Slide 0-1 Copyright © 2003 Pearson Education, Inc. Figure: Overzicht Informatica College 1 - September 5 (Docent: Frank Seinstra) Computer Science an overview.

Slide 0-50 Copyright © 2003 Pearson Education, Inc.

Tot slot

• Lees ook Hoofdstuk 0

• Leuk om te lezen: ‘Social Issues’

• Denk na over de schrijf-opdracht!