Principles of It ITBP 103: Unit 1 Computation
Principles of It ITBP 103: Unit 1 Computation
ITBP 103
UNIT 1
COMPUTATION
This unit illustrates the ability of computers
to mechanize and amplify intellectual
activities to process problems systematically.
CIT, UAEU.
3 Unit Contents
1. Computational Thinking
Problem Solving
Problem Specification
Data Organization and Analysis
Abstraction, Modeling and Simulation
Automation
2. Algorithms
Variables
Assignment
Instructions
Sequence
3. Logic
Proposition
Boolean Variables
Logical Operators and Truth Tables
4. Flowcharts
Symbols
Applications
CIT, UAEU.
4
COMPUTATIONAL
THINKING
CIT, UAEU.
5 Computational Thinking
CIT, UAEU.
6 Computational Thinking
Decomposition
Make a Party
Definition 1:
Invite People Prepare Food
Solving a complex
problem by breaking it Write down names
Get Cookbook
Wait a day
down into smaller more Check list
Look for suggestions
Decide on food
Add names
manageable parts.
Get phone numbers Shop for ingredients
Call guests Cook food
Mark called guests
CIT, UAEU.
7 Computational Thinking
Decomposition
cards
8 Computational Thinking
Decomposition
cards
9 Computational Thinking
Problem Formulation
Definition 2:
Problems formulation to enable computers to help solve
them
A problem is formulated precisely by Initial State
Precondition
what to accomplish, without any (or Input)
Specification Examples:
Precondition Postcondition
Square root
n >0 value of n
n =5 s um (1, 2, ..., n) ?
Definition 3:
Logical organization and analysis of data
Data Examples:
Problem: Data:
How does UAE Government allocates Number of students at UAE
budget to UAE university ? University
Exercise
Think of other problems that could be
computationally solved through data
organization and analysis
CIT, UAEU.
14 Computational Thinking
Abstraction, Model and Simulation
Definition 4:
Representing real-world domains through
abstractions to derive models and simulations
Expected evolution of a storm
http://en.wikipedia.org/wiki/Computer_simulation
15 Computational Thinking
Abstraction, Model and Simulation
Examples:
SIMULATIONS
You used them without
knowing!
17 Computational Thinking
Abstraction, Model and Simulation
Exercise
Discuss some simulator examples and
highlight the abstraction levels (i.e. what
has been hidden).
CIT, UAEU.
18 Computational Thinking
Algorithm
Definition 5:
Automating solutions through algorithmic steps
Are you in
restaurant?
Examples:
A cooking recipe
Assembly instructions for a model
The rules of how to play a game
VCR user guide
Description of a martial arts technique
Directions for driving from A to B
A knitting pattern
A car repair manual
CIT, UAEU.
21 Computational Thinking
Algorithm
Algorithm
Step 1: Start
Step 2: Get the first number
Step 3: Get the second number
Step 4: Calculate the summation by adding the first number
to the second number
Step 5: Print the summation
Step 6: Stop
22 Computational Thinking
Algorithm
Algorithm
Step 1: Start
Step 2: Get the four marks
Step 3: Calculate the final grade by adding the fours marks then divide by 4
Step 4: if the final grade is less than 60 then
Print “FAIL”
else
Print “PASS”
Step 5: Stop
23 ALGORITHMS
CIT, UAEU.
24 Algorithms
History
Muhammad ibn Musa Al-Khwarizmi is the founder of Algorithm as
well as Algebra, Calculus, and other basic concepts in mathematics
25 Algorithms
Definition
A sequence of instructions describing how to do a task.
Proble
m
Algorithm: A sequence of instructions
describing how to do a task (or a process)
Java Program
27 Components of an Algorithm
Instructions
Procedures
Selections
CIT, UAEU.
28 Components of an Algorithm
Instructions
Procedures
Selections
CIT, UAEU.
29 Values
Example:
Recipe ingredients
30 Variables
10 cookies
50 grams of sugar
This jar 3 slices of cake
can
contain etc.
31 Variable Assignment
Y2
X 5Y + 16
On the left side of , we put the name of a variable and on
the right side we put a value or an expression.
Each variable refers to a unique location in computer memory
that contains a value. Name Value
Y 2 X 26
32 Restriction on Variables
Instructions
Procedures
Selections
CIT, UAEU.
34 Instructions
Algorithm
Step 1: Start
Step 2: Get the first number
Step 3: Get the second number
Step 4: Calculate the summation by adding the first number
to the second number
Step 5: Print the summation
Step 6: Stop
36 Pseudocode - Definition
Logical flow
Step 1: Start
Step 2: Calculate Sum 10 + 20
Step 3: Print Sum
Step 4: Stop
39 Pseudocode
Step 1: Start
Step 2: Set Num1 10 INPUT
Step 1: Start
Step 2: Input Num1
Step 3: Input Num2
Step 4: Calculate Sum Num1 + Num2
Step 5: Print Sum
Step 6: Stop
41 Pseudocode
Pseudocode:
Step 1: Start
Step 2: Input L, W
Step 3: Calculate A L x W
Step 4: Print A
Step 5: Stop
42 Pseudocode
Pseudocode:
Step 1: Start
Step 2: Input LFT
Step 3: Calculate LCM LFT x 30
Step 4: Print LCM
Step 5: Stop
43 Components of an Algorithm
Instructions
Procedures
Selections
CIT, UAEU.
44 Procedure
Example:
Drive_To_Uni
45 Procedure Example
procedure Drive_To_Uni
{
1. find car keys
2. disable car alarm ...etc...etc...etc...
3. open car door 52. find parking space
4. get in car 53. pull into parking
5. shut car door space
6. put keys in ignition 54. turn off engine
7. start car 55. remove keys from
ignition
8. back car out of
driveway 56. open car door
9. drive to end of street 57. get out
10. turn right 58. shut car door
11. drive to end of street 59. lock car door
12. turn left 60. enable alarm
...etc...etc...etc }
46 Procedure Example (Cont)
Instructions
Procedures
Selections
CIT, UAEU.
48 Selection
Examples:
Car repair
49 Selection
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
}
else
{
CheckDistributor
CheckIgnitionCoil
}
50 Selection
if (motor turns)
then
{ Should be a
CheckFuel true or false
CheckSparkPlugs
CheckCarburettor
condition.
}
else
{
CheckDistributor
CheckIgnitionCoil
}
51 Selection
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
Sequence if
}
else the condition
{ is true.
CheckDistributor
CheckIgnitionCoil
}
52 Selection
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
} Sequence if the
else
{ condition is false.
CheckDistributor
CheckIgnitionCoil
}
53 LOGIC
CIT, UAEU.
54 Logic
x is greater than 2
P NOT P
P: “Today is Friday”
F T
T T T
T T T
Example:
b: “you are an IT major”
c: “you are a freshman”
Translate the following English sentences into logical
expression:
You are an IT major or you are a freshman
You are an IT major or you are not a freshman
Flowchart
Pseudocode START
STOP
STOP
66 Flowcharts
Algorithm
-Start
Flowchart
-Start
-Get
-Get the
the four
four marks
marks
-Calculate
-Calculate thethe final
final grade
grade by
by adding
adding the
the fours
fours marks
marks then
then divide
divide by
by 4
4 START
START
-if the final grade is less than 60 then
-if the final grade is less than 60 then
Print
Print “FAIL”
“FAIL” Input
else
else M1, M2, M3, M4
Print
Print “PASS”
“PASS”
-Stop
-Stop
Calculate
GRADE(M1+M2+M3+M4)/4
Pseudocode
Step 1: Start N Y
IS
IS
Step 2: Input M1, M2, M3, M4 GRADE<6
GRADE<6
Step 3: Calculate GRADE (M1+M2+M3+M4)/4 0
0
Step 4: if (GRADE <60) then
Print “FAIL” Print Print
Print
“PASS” “FAIL”
else
Print “PASS”
endif
Step 5: Stop STOP
STOP
67 Flowcharts
Exercise
Draw a flowchart that reads the two sides
of a rectangle then calculate and print its
area.
68 Concept Check
Across
Down