Information Input and Output

Download Report

Transcript Information Input and Output

Algorithm & Program
Week 5
Learning Outcomes
• By the end of this session, students will
understand how to create computer
software. Students will learn :
– Algorithm
– Program
– Analytic & numeric solution.
Algorithm & Program
• Algorithm is a method for carrying out a specific
calculation that is guaranteed to produce a result in a
finite number of steps.
• However, some results cannot be obtained by an
algorithm [Findlay, Watt,1985].
• Although algorithms can produce results, sometimes it
may no be feasible to use them in practice (e.g. too slow
execution, too much store).
• A heuristic approach is used in the field of artificial
intelligence.
• Programs are working models of algorithms and
heuristics.
Simple Algorithm to Find an Integration
Result (1)
• Integration is basically a summation.
• A mathematical function may be divided into a
large finite numbers which constitutes a series of
square area.
• Summing all these squares would produce the
integration results.
• Rather than producing the integration result in
an analytical way (as in Calculus), the
integration result can be obtained numerically
(the way a computer does).
Simple Algorithm to Find an Integration
Result (2)
f(x)
f(x)
x
a
b
Algorithm :
1. Divide a function into a small step of delta x, delta x = (b-a)/n
2. x = a
3. Find the value of y1= f(x)
3a. y1=y1*delta x
4, Increase the value of x by delta x, x = x + deltax
5. Find the value of y2=f(x)
5a. y2 = y2*delta x
6. A= y1+y2
7 y1=y2
8 Back to 4
x
Simple Program
Program Integration (input, output)
Declare variables
Begin
.
.
.
Algorithm
.
.
End.
Important Terms
•
•
•
•
•
•
•
Low Level Language
High Level Language
Translator
Source Code
Object Program
Compilation
Execution
Important Terms
• Analytic solution
• Numeric solution
• Flow chart