Geology Reference
In-Depth Information
Appendix 2: Algorithms and Data
Structures
value
to
the
variable
var .
For
example,
the
A2.1 Algorithms
assignment:
a c C x 2 - 2
There are three basic components of any software
system. They are: (1) a data collection, (2) a set
of algorithms , and (3) a system of memory data
structures . Data can be classified as numerical
data , strings ,and compound data . Numerical
data are binary representations of natural, inte-
ger, or real numbers. Strings are sequences of
symbols of alphabets , for example the ASCII
or UNICODE alphabets. Finally, compound data
are values that contain heterogeneous subsets of
information (numbers, strings, etc.), typically in
fixed number and sequence. The elements of
compound data records are usually called fields .
An algorithm is an ordered sequence of instruc-
tions for a virtual or real processing unit. There
are three fundamental classes of instructions. The
first class includes assignments of the form:
requires reading of the value of variable x ,com-
putation of the second power of this value, read-
ing of the value of variable c , addition between
these two values, finally addition of the constant
2. The resulting value is then assigned to the
variable a . Expressions may also contain func-
tion calls , which invoke execution of specialized
code for the calculation of common mathematical
functions or other code that must be executed
several times. For example,
a y C x 2 - 2 sin. z /
invokes the execution of the sine function during
the evaluation of the expression. In this instance,
the instruction is executed first calling the func-
tion sin (), to which the value of z is passed,
then using the return value of this function in
the evaluation of the expression. A second class
of algorithm instructions allows to control the
program flow , that is, the sequence of instructions
that will be executed after certain steps. Program
flow control instructions do not execute complex
mathematical operations and do not perform as-
signments. They simply evaluate the state of a
logical variable (a variable whose values can be
true or false ), or a logical expression, and decide
the number of the next instruction to be executed
through a jump instruction. For example, the
instruction:
var expr
(A2.1)
where var is a variable , that is, a memory location
where we can store a value, and expr is an
expression that combines a homogeneous set
of variables and constants through arithmetical,
logical, or string operators, depending from the
expression type. Differently from physics, in
computer science the fundamental distinction
between variables and constants is not based on
their capability to change their value. Variables
are named memory locations that may contain or
not a value. Constants are parameter values,
generally
stored
within
the
algorithm
code.
#5 W :::
#6 W x 10 ) jump #20
#7 W :::
The
operation
involved
into
the
assignment
instruction
( A2.1 )
includes
the
evaluation
of
the
expression
and
the
assignment
of
the
Search WWH ::




Custom Search