Lect 2
Lect 2
Algorithms
Dr.Associate Professor
/Abdualmajed Al-Khulaidi
Algorithm Definition
An algorithm is a specific set of instructions that
perform a specific function.
It must fulfill the following conditions:
1-(Input)
2-(Output)
3-(Definiteness)
4-(Finiteness )
5-(effectiveness)
(Algorithm Analysis )
Algorithm analysis:
It is the determination of the efficiency of the algorithm and then its
improvement, as there are two measures that are directly related to
the achievement of the algorithm, namely:
1- (Space Complexity) It is the amount of memory required to run the
program until its completion, as this type depends on two parts:
A- Fixed part: or independent from the input and output
characteristics, as this part includes the instruction space, the space
assigned to the variables, whether simple or complex variables of fixed
size in addition to the space of the constants, ... etc.
B- A variable part: It consists of the space required by the program
with the complex variables, the size of which depends on the example
of the problem to be solved.
(Algorithm Analysis )
2-Time Complexity:
Time complexity: The amount of time the code
or algorithm takes to process or accomplish the
task.
Types of time complications
You can express time complexity with (Big O Notation). Big O notation expresses the running time of the
algorithm in terms of how fast it grows in relation to the input (this input is called "n").
Time Constant Complexity: O (1)