algorithmic thinking - yonsei university thinking.pdf · adding two integer numbers computer...
TRANSCRIPT
1 1
Holistic Education II : Computational Thinking Holistic Education II : Computational Thinking
Algorithmic Thinking
2 2
Algorithms
• Many of life’s essential activities involve following a sequence of simple and discrete steps to solve some large problem.
• Algorithm is a sequence of discrete actions that will result in achieving some goal or solving some problem.
Complex Process
Sequence of actions
input output
Algorithm
3 3
Algorithms in daily life
Football Players: when execute a play on the field
Piano Players: when read and play a musical score
Actors: when read and execute a script for performance
Drivers: when follow to getting from one city to another
5 5
The Properties of Algorithm
1. Be Meaningful(Semantics) refers to the meaning of the actions that occur in an algorithm
2. Be Unambiguous the action is not subject to conflicting interpretations
action must have only one possible interpretation
3. The Order be defined the directions describe an orderly sequence of discrete actions
4. Be Finite we can not reach the goal if we are required to follow a never-ending
sequence of actions
6 6
Software and Programming Languages
A computer is able to perform simple actions such as adding two integer numbers
Computer software(program) provides the instructions for telling a computer the algorithm (actions) that it should follow to achieve some goal
How to express the algorithm in computer? We need the Programming Language
A programming language is a language that is designed to precisely and compactly express computational algorithm
The computer can understand what they have to act There are many types of language
7 7
Actions
Since any executable algorithm must be expressed as a sequence of possible actions, we must first understand what actions a computer might possible take
The ways of expressing algorithms and computational processes Name Binding Selection Repetition Modularization
8 8
Name Binding (proper naming & state)
Name binding is the association of a name with a value Ex) X 3 Y 4 Z 3 + 4
Proper naming enables a computer scientist to more clearly reason about the algorithm and data of the program
Ex) DollarsPerGallon 3.75 TankCapacity 10
DollarsToFill TankCapacity * DollarsPerGallon
The computational state of a program is the collection of name bindings that are active at any single point in time
Fahrenheit
State.value
9 9
Selection (one-way)
Control flow statements are commands that control the specific ordering of the actions performed by a computer program
One-way selection: Perform an action or skip the action
11 11
Selection (multiway)
Multiway selection : use elseif instead of else to cascade two-way selections
12 12
Repetition
Computers must also execute a sequence of actions repeatedly in order to achieve some greater outcome
A loop is a control structure that repeatedly executes a sequence of actions
While loop
13 13
Modularization
Modularization is a vital element of programming that allows us to define new computable actions by assigning a name to some computable process
Algorithms can be modularized by breaking them into independent sub-processes
14 14
Modularization: Well-designed modules
Well-designed modules should meet several criteria Understandability Encapsulation Composition
15 15
Modularization : Modularity
Modularity is an extremely powerful technique for designing complex algorithms
16 16
Modularization : Module Flexibility
Modules are made flexible by allowing users to feed input values into the code
Inputs: “parameters”
17 17
(EX) Modularization : Module Flexibility
Optimize the flexibility of grillSteak module
grillSteak(65, 130, 2) The steak to be grilled from a starting point of 65 degrees until it reaches a
temperature of at least 130 degree where the temperature increases by 2 degree for every three minutes of grill time
grillSteak(94, 155, 13) The steak to be grilled from a starting point of 94 degrees until it reaches a
temperature of at least 155 degree where the temperature increases by 13 degree for every three minutes of grill time