Download - Computational Thinking
Einführung in die Informatik
1. Computational Thinking
Prof. O. Nierstrasz
Institut für Informatik und angewandte Mathematik
© Oscar Nierstrasz 2
Roadmap
> What is Computer Science?
> Computational Thinking
> Modeling
> Software Engineering
Computational Thinking
© Oscar Nierstrasz 3
Roadmap
> What is Computer Science?
> Computational Thinking
> Example: Recursion
> Modeling
> Software Engineering
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
What is Computer Science … not
© Oscar Nierstrasz
Computational Thinking
5
Computer Science is not
• hacking
• programming
• technology
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
© 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
© Oscar Nierstrasz 8
Roadmap
> What is Computer Science?
> Computational Thinking
> Example: Recursion
> Modeling
> Software Engineering
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
Abstraction
© Oscar Nierstrasz
Computational Thinking
10
Abstractions strip away
details to help us cope
with complexity
Decomposition & Separation of concerns
© Oscar Nierstrasz
Computational Thinking
11
We decompose
complex tasks
by separating
concerns
Parallel algorithms
© Oscar Nierstrasz
Computational Thinking
12
By distributing tasks to
many workers, we get
more done in the same
amount of time
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
Planning and optimization
© Oscar Nierstrasz
Computational Thinking
14
Planning may require
sophisticated analysis of
multiple scenarios
Pipelining
© Oscar Nierstrasz
Computational Thinking
15
Pipelining makes efficient use of expensive resources
Interpreting data as code and code as data
© Oscar Nierstrasz
Computational Thinking
16
We process instructions before acting on them
Distinguishing humans from computers
© Oscar Nierstrasz
Computational Thinking
17
Certain tasks are known to be difficult for computers to solve
Concurrency control
© Oscar Nierstrasz
Computational Thinking
18
Contention for shared resources can lead to both
safety problems and liveness problems.
Simulation
© Oscar Nierstrasz
Computational Thinking
19
Expensive experiments
can be replaced by
inexpensive simulations
© Oscar Nierstrasz 20
Roadmap
> What is Computer Science?
> Computational Thinking
> Example: Recursion
> Modeling
> Software Engineering
Computational Thinking
Recursion
© Oscar Nierstrasz
Computational Thinking
21
re•cur•sion |riˈkərZHən|noun Mathematics & Linguistics
See RECURSION.
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.
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)?
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?
Binary search
© Oscar Nierstrasz
Computational Thinking
25
Many navigation problems can be
effectively solved using recursion.
Depth-first-search with backtracking
© Oscar Nierstrasz
Computational Thinking
26
Many search problems
can be solved with the
help of backtracking
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
∞
∞
∞∞
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 ∞
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
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
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
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
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
© Oscar Nierstrasz 34
Roadmap
> What is Computer Science?
> Computational Thinking
> Example: Recursion
> Modeling
> Software Engineering
Computational Thinking
Modeling
© Oscar Nierstrasz
Computational Thinking
35
A model captures certain properties of interest of a subject
Human models capture how clothes might look on us (or not)
© Oscar Nierstrasz
Computational Thinking
36
Models only stand
in for the real thing
Blueprints specify a design
© Oscar Nierstrasz
Computational Thinking
37
Models as specifications
allow us to reason about
a thing before we have
built it.
Physical models let us test feasibility of designs
© Oscar Nierstrasz
Computational Thinking
38
Scale models only capture
some aspects of reality.
Finite state models express states and transitions of a process
© Oscar Nierstrasz
Computational Thinking
39
Turing machines model computability
© Oscar Nierstrasz
Computational Thinking
40
We use mathematical models to reason
about computability and complexity
Computer graphics models capture visual aspects of real (or imagined) objects
© Oscar Nierstrasz
Computational Thinking
41
Different models express different properties
Business models support decision making
© Oscar Nierstrasz
Computational Thinking
42
A business model expresses the core values of a business
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.
Programming is modeling
© Oscar Nierstrasz
Computational Thinking
44
© Oscar Nierstrasz 45
Roadmap
> What is Computer Science?
> Computational Thinking
> Example: Recursion
> Modeling
> Software Engineering
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
€
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
Conclusion
© Oscar Nierstrasz
Computational Thinking
48
Software Engineering builds bridges
between users and technology
Programming is modeling
Computer science requires computational thinking