computational thinking

48
Einführung in die Informatik 1. Computational Thinking Prof. O. Nierstrasz Institut für Informatik und angewandte Mathematik

Upload: oscar-nierstrasz

Post on 12-Jul-2015

611 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Computational Thinking

Einführung in die Informatik

1. Computational Thinking

Prof. O. Nierstrasz

Institut für Informatik und angewandte Mathematik

Page 2: Computational Thinking

© Oscar Nierstrasz 2

Roadmap

> What is Computer Science?

> Computational Thinking

> Modeling

> Software Engineering

Computational Thinking

Page 3: Computational Thinking

© Oscar Nierstrasz 3

Roadmap

> What is Computer Science?

> Computational Thinking

> Example: Recursion

> Modeling

> Software Engineering

Computational Thinking

Page 4: Computational Thinking

Schedule

Datum Thema Dozent

23-Sep-10 Computational Thinking Nierstrasz

30-Sep-10 EndlicheAutomaten, reguläreAusdrücke Studer

7-Oct-10 Programmiersprachen, -paradigmen und -technologie Nierstrasz

14-Oct-10 Computernetze Staub

21-Oct-10 Betriebssysteme Staub

28-Oct-10 Datenbanken und Privacy Studer

4-Nov-10 Syntax und Semantik Jäger

11-Nov-10 Programme und Beweise Jäger

18-Nov-10 Diskretisierung/Signalverarbeitung Zwicker

25-Nov-10 Simulation Zwicker

2-Dec-10 Berechenbarkeit Strahm

9-Dec-10 Komplexität Strahm

16-Dec-10 Repetition Assistenten

23-Dec-10 TBA

11-Jan-11 Prüfung

© Oscar Nierstrasz

Computational Thinking

4

Page 5: Computational Thinking

What is Computer Science … not

© Oscar Nierstrasz

Computational Thinking

5

Computer Science is not

• hacking

• programming

• technology

Page 6: Computational Thinking

What is Computer Science?

© Oscar Nierstrasz

Computational Thinking

6

Computer Science is about building bridges between

user problems and technological solutions

Real-world domain Technology domain

Page 7: Computational Thinking

© Oscar Nierstrasz

Computational Thinking

7

Übersicht

Informatik

Theorie

(Automaten und formale

Sprachen, Berechenbarkeit,

Komplexität, Logik,

Algorithmen)

Praxis

(Programmiersprachen,

Betriebssysteme,

Netzwerke &Verteilte

Systeme, Software

Engineering, Datenbanken,

Rechnerarchitektur)

Schnittstellen zur Aussenwelt

(Mensch-Maschine Schnittstelle, Computer-

vision, Computergrafik, Sensornetze,

Künstliche Intelligenz, Computerlinguistik)

Wirtschaftsinformatik

Anwendungs-

software

Wissenschaftliche

Anwendungen

(Modellierung und Simulation,

Biologie, Physik, Chemie,

Sozialwissenschaften, etc.)

Informatikstudium Andere Studiengänge

Mathematik

Page 8: Computational Thinking

© Oscar Nierstrasz 8

Roadmap

> What is Computer Science?

> Computational Thinking

> Example: Recursion

> Modeling

> Software Engineering

Computational Thinking

Page 9: Computational Thinking

Computational Thinking

© Oscar Nierstrasz

Computational Thinking

9

“Computational thinking is a way of solving problems,

designing systems, and understanding human

behavior that draws on concepts fundamental to

computer science”

— Jeannette M. Wing, CACM 2006

Page 10: Computational Thinking

Abstraction

© Oscar Nierstrasz

Computational Thinking

10

Abstractions strip away

details to help us cope

with complexity

Page 11: Computational Thinking

Decomposition & Separation of concerns

© Oscar Nierstrasz

Computational Thinking

11

We decompose

complex tasks

by separating

concerns

Page 12: Computational Thinking

Parallel algorithms

© Oscar Nierstrasz

Computational Thinking

12

By distributing tasks to

many workers, we get

more done in the same

amount of time

Page 13: Computational Thinking

Prefetching and cacheing

© Oscar Nierstrasz

Computational Thinking

13

Prefetching = get what you need

before you need it

Cacheing = keep handy

whatever you will need again

Page 14: Computational Thinking

Planning and optimization

© Oscar Nierstrasz

Computational Thinking

14

Planning may require

sophisticated analysis of

multiple scenarios

Page 15: Computational Thinking

Pipelining

© Oscar Nierstrasz

Computational Thinking

15

Pipelining makes efficient use of expensive resources

Page 16: Computational Thinking

Interpreting data as code and code as data

© Oscar Nierstrasz

Computational Thinking

16

We process instructions before acting on them

Page 17: Computational Thinking

Distinguishing humans from computers

© Oscar Nierstrasz

Computational Thinking

17

Certain tasks are known to be difficult for computers to solve

Page 18: Computational Thinking

Concurrency control

© Oscar Nierstrasz

Computational Thinking

18

Contention for shared resources can lead to both

safety problems and liveness problems.

Page 19: Computational Thinking

Simulation

© Oscar Nierstrasz

Computational Thinking

19

Expensive experiments

can be replaced by

inexpensive simulations

Page 20: Computational Thinking

© Oscar Nierstrasz 20

Roadmap

> What is Computer Science?

> Computational Thinking

> Example: Recursion

> Modeling

> Software Engineering

Computational Thinking

Page 21: Computational Thinking

Recursion

© Oscar Nierstrasz

Computational Thinking

21

re•cur•sion |riˈkərZHən|noun Mathematics & Linguistics

See RECURSION.

Page 22: Computational Thinking

Avoiding infinite recursion

© Oscar Nierstrasz

Computational Thinking

22

re•cur•sion |riˈkərZHən|noun Mathematics & Linguistics

If you still don’t get it, see RECURSION.

To prove termination, you must show that

recursion will reach a base case.

Page 23: Computational Thinking

Example: factorial

© Oscar Nierstrasz

Computational Thinking

23

fact(n) = n × fact(n-1)

fact(0) = 1

fact(5) = 5 × fact(4)

= 5 × 4 × fact(3)

= 5 × 4 × 3 × fact(2)

= 5 × 4 × 3 × 2 × fact(1)

= 5 × 4 × 3 × 2 × 1 × fact(0)

= 120

Looks good, but what is fact(-1)?

Page 24: Computational Thinking

Example: greatest common divisor

© Oscar Nierstrasz

Computational Thinking

24

gcd(a,0) = a

gcd(a,b) = gcd(b, a mod b)

gcd(63, 91) = gcd(91, 63)

= gcd(63, 28)

= gcd(28, 7)

= gcd(7, 0)

= 7

How do we know that

gcd(a,b) always terminates

for positives integers a and

b?

Page 25: Computational Thinking

Binary search

© Oscar Nierstrasz

Computational Thinking

25

Many navigation problems can be

effectively solved using recursion.

Page 26: Computational Thinking

Depth-first-search with backtracking

© Oscar Nierstrasz

Computational Thinking

26

Many search problems

can be solved with the

help of backtracking

Page 27: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

27

E

F

DC

B

A

14

9

2

11

6

9

7

1015

0

∞∞

Page 28: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

28

E

F

DC

B

A

14

9

2

11

6

9

7

1015

7

0

14

9 ∞

Page 29: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

29

E

F

DC

B

A

14

9

2

11

6

9

7

1015

7

0

14

9 < 7 + 10 4 + 15 = 22

Page 30: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

30

E

F

DC

B

A

14

9

2

11

6

9

7

1015

7

0

14 > 9 + 2

9 22 > 9 + 11

Page 31: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

31

E

F

DC

B

A

14

9

2

11

6

9

7

1015

7

0

11

20

9 20

Page 32: Computational Thinking

Finding the shortest path from A to F

© Oscar Nierstrasz

Computational Thinking

32

E

F

DC

B

A

14

9

2

11

6

9

7

1015

7

0

11

20 < 20 + 6

9 20

Page 33: Computational Thinking

Breadth-first vs depth first

Breadth-first

> Exhaustive — finds all solutions

> Must keep track of all nodes in a level

> Will find shortest path first

Depth-first

> Finds first solution

> Only keep track of current path — can use a stack

> May be unlucky in searching

© Oscar Nierstrasz

Computational Thinking

33

Page 34: Computational Thinking

© Oscar Nierstrasz 34

Roadmap

> What is Computer Science?

> Computational Thinking

> Example: Recursion

> Modeling

> Software Engineering

Computational Thinking

Page 35: Computational Thinking

Modeling

© Oscar Nierstrasz

Computational Thinking

35

A model captures certain properties of interest of a subject

Page 36: Computational Thinking

Human models capture how clothes might look on us (or not)

© Oscar Nierstrasz

Computational Thinking

36

Models only stand

in for the real thing

Page 37: Computational Thinking

Blueprints specify a design

© Oscar Nierstrasz

Computational Thinking

37

Models as specifications

allow us to reason about

a thing before we have

built it.

Page 38: Computational Thinking

Physical models let us test feasibility of designs

© Oscar Nierstrasz

Computational Thinking

38

Scale models only capture

some aspects of reality.

Page 39: Computational Thinking

Finite state models express states and transitions of a process

© Oscar Nierstrasz

Computational Thinking

39

Page 40: Computational Thinking

Turing machines model computability

© Oscar Nierstrasz

Computational Thinking

40

We use mathematical models to reason

about computability and complexity

Page 41: Computational Thinking

Computer graphics models capture visual aspects of real (or imagined) objects

© Oscar Nierstrasz

Computational Thinking

41

Different models express different properties

Page 42: Computational Thinking

Business models support decision making

© Oscar Nierstrasz

Computational Thinking

42

A business model expresses the core values of a business

Page 43: Computational Thinking

Software models express architecture and design

© Oscar Nierstrasz

Computational Thinking

43

The Unified Modeling

Language (UML)

consists of several

different types diagrams

to describe software

designs, architectures,

and requirements

models.

Page 44: Computational Thinking

Programming is modeling

© Oscar Nierstrasz

Computational Thinking

44

Page 45: Computational Thinking

© Oscar Nierstrasz 45

Roadmap

> What is Computer Science?

> Computational Thinking

> Example: Recursion

> Modeling

> Software Engineering

Computational Thinking

Page 46: Computational Thinking

Software Engineering

© Oscar Nierstrasz

Computational Thinking

46

Software Engineering consists of

• processes and techniques

• to develop software products

• within a given budget and deadline and

• satisfying functional and quality requirements

Page 47: Computational Thinking

How Software Engineering bridges domains

© Oscar Nierstrasz

Computational Thinking

47

capture and model

requirements

architecture, design,

implementation

quality assurance and testing

Real-world domain Technology domain

Page 48: Computational Thinking

Conclusion

© Oscar Nierstrasz

Computational Thinking

48

Software Engineering builds bridges

between users and technology

Programming is modeling

Computer science requires computational thinking