P6 Discuss How Asymptotic Analysis Can Be Used To Assess The Effectiveness of An Algorithm
P6 Discuss How Asymptotic Analysis Can Be Used To Assess The Effectiveness of An Algorithm
Asymptotic Analysis
For example, the running time of one operation is computed as f(n) and may be for another
operation it is computed as g(n2). This means the first operation running time will increase
linearly with the increase in n and the running time of the second operation will increase
exponentially when n increases. Similarly, the running time of both operations will be nearly the
same if n is significantly small.
(GeeksforGeeks, 2019)
How it can be used to find effectiveness of an algorithm
They are finding out more effectiveness of an algorithm can be used so we time required by
algorithm falls under the three types: Worst case maximum time required by an algorithm and it
is mostly or done while analyzing the algorithm.
The commonly used notation for calculating the running time complexity of the algorithm as
follows:
Big O notation
Big θ notation
Big notation
Big Oh Notation, O
Hence, function g (n) is upper bound for function f (n), as g (n) grows faster than f (n)
For Example:
The notation Ω (n) is the formal way to express the lower bound of an algorithm’s running
time. It measures the best-case time complexity or the best amount time an algorithm can
possibly take to complete. The function f (n) = Ω (g (n)) [“f of n is omega of g of n”] if and
only if there exists positive constant c and no such that
K1 = 7
The notation θ (n) us the formal way to express the lower bound of an algorithm running time.
It measures the best-case time complexity or the best amount of time an algorithm can possibly
take to complete. The function f (n) = θ (g (n)) [“f is the theta of g of n”] if and only if there
exists positive constant k1, k2 and k0 such that (DataCamp Community, 2019)
For Example:
k1 = 3, k2 = 4 and n0 = 2
The Theta Notation is precise than both the big – oh and Omega notation. The function f (n) =
function f (n) = θ (g (n)) if g(n) is both an upper and lower bound.
They more efficiency of an algorithm can be measured can performs better than second so inputs
second perform better. They can work better on machine in inputs such as
1. Time complexity
2. Space complexity
3. Complexity theory
Time complexity
Example
Here
In this case, in each assign the number, light, iteration of i, inner loop is executed 'n' times. The
time complexity of a loop is equal to the number of times the innermost statement is to be
executed. Additionally, we will stir this up with one more addition at the end. So, this is how we
stand at the moment: 2 declarations, 2 assignments, n comparisons, n additions, n assignments, 1
Total cost = 1 + 1 + n + n + n+ n + 1 + n
= 4n + 3
T(n) = 4n + 3 = O(n)
Space complexity
Space complexity is an algorithm is total space take by algorithm with regard to input size. Space
complexity both auxiliary space and space used by input. They execute an algorithm can be
loaded in memory. The memory can be used in different forms are
1. Variable
2. Program instruction
3. Execution
1. Instruction Space can used to store the addresses while a module calls another module or
functions during execution
2. Data space can use to store data, variables and constants which ae stored by the program
and updated during execution.
(Tutorialspoint.com, 2019)
Example
Instance of RoadRunnable () three parameter are store variable: roadNumber, TraffcLight aLight
To store queue = 3
To store i = n
Space complexity = n + 3
Complexity theory
Complexity theory is direct application to computability theory and use of computation model
such as Turing machines to help test the complexity. Complexity theory helps for programmer
relate and group problems together into complexity classes. If one problem can solve, it opens a
way to solve a particular problem. For example, some problems can solve in polynomial amounts
of time and others take exponential amounts of time to the input the size.
They more efficiency of an algorithm can be measured can performs better than second so inputs
second perform better. They can work better on machine in inputs such as
1. Time complexity
2. Space complexity
3. Complexity theory
Time complexity
Example
Here
In this case, in each assign the number, light, iteration of i, inner loop is executed 'n' times. The
time complexity of a loop is equal to the number of times the innermost statement is to be
executed. Additionally, we will stir this up with one more addition at the end. So, this is how we
stand at the moment: 2 declarations, 2 assignments, n comparisons, n additions, n assignments, 1
= 4n + 3
T(n) = 4n + 3 = O(n)
Space complexity
Space complexity is an algorithm is total space take by algorithm with regard to input size. Space
complexity both auxiliary space and space used by input. They execute an algorithm can be
loaded in memory. The memory can be used in different forms are
1. Variable
2. Program instruction
3. Execution
1. Instruction Space can used to store the addresses while a module calls another module or
functions during execution
2. Data space can use to store data, variables and constants which ae stored by the program
and updated during execution.
(Tutorialspoint.com, 2019)
Example
Instance of RoadRunnable () three parameter are store variable: roadNumber, TraffcLight aLight
To store queue = 3
To store i = n
Space complexity = n + 3