3. OBJECTIVE
To learn the definition of algorithm complexity
To learn types of algorithm complexity
4. COMPLEXITY OF ALGORITHM
• A problem may have many solving algorithm.
• An algorithm must not only correct, but also efficient.
• Efficiency of algorithm is measured by how much time
and space memory required to run it.
• An efficient algorithm can minimizes the time and space
requirements.
• The need for time and space an algorithm depends on
the size of the input (n), which show the amount of data
processed.
5. “Algorithm complexity is something designed to compare
two algorithms at the idea level - ignoring low-level details
such as the implementation programming language, the
hardware the algorithm runs on, or the instruction set of
the given CPU”
“Complexity is also a tool that allows us to explain how an
algorithm behaves as the input grows larger”
6. Cont. . .
• Quantity that used to explain an abstract model of measurement of
time / space is the complexity of algorithms.
• There are two kinds of algorithm complexity:
– The complexity of time T(n)
– The complexity of space S(n)
• Using the scale complexity of the time/space algorithm, we can
determine the rate of increase time (space) required by algorithms
with increasing input size n
• Abstract model of measurement of time / space should be
independent of any machine and compiler consideration.
7. Why Do We Need An Efficient Algorithm ?
105 15 20 25 30 35 40
Ukuran masukan
10
102
103
104
105
1
1 detik
1 menit
1 jam
1 hari
Waktukomputasi(dalamdetik)
10-1
10-4 x 2n
10-6 x n3
10-6 x 2n
10-4 x n3
8. TIME COMPLEXITY
• But the computation time requirement as above is less
acceptable:
– In practice we do not have real time information on how to
performa particular operation
– A computer with a different architecture would be different
durations for each type of operation.
• In addition, the program execution time is also influenced
by the programming language compiler used.
9. Types Of Time Complexity
• Tmax (n): the time complexity for the worst case,
the maximum time requirement.
• Tmin (n): the time complexity for the best case,
the minimum time requirement.
• Tavg (n): the time complexity for the average
case, the average time requirement
10. Space Complexity
• The complexity of space S(n) : measured by
memory used to structure of data is contained in
the algorithm as a function of the input size n