Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
21 views

Algorithm Analysis: Ms. Uma. S

This document discusses algorithm analysis and complexity. It defines an algorithm as a list of instructions to solve a problem. Algorithm complexity is measured by time and space complexity, which give the running time or space needed based on input size. Time complexity T(n) gives the maximum number of steps, while space complexity S(n) gives the maximum memory. Asymptotic notation like Big O, Big Omega, and Big Theta are used to classify algorithms by their worst-case, best-case, and average-case running times. Big O gives an upper bound and indicates an algorithm takes O(n) time in the worst case.

Uploaded by

Amirtha Varshini
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Algorithm Analysis: Ms. Uma. S

This document discusses algorithm analysis and complexity. It defines an algorithm as a list of instructions to solve a problem. Algorithm complexity is measured by time and space complexity, which give the running time or space needed based on input size. Time complexity T(n) gives the maximum number of steps, while space complexity S(n) gives the maximum memory. Asymptotic notation like Big O, Big Omega, and Big Theta are used to classify algorithms by their worst-case, best-case, and average-case running times. Big O gives an upper bound and indicates an algorithm takes O(n) time in the worst case.

Uploaded by

Amirtha Varshini
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Algorithm Analysis

Ms. UMA. S
Time Space Trade-Off

An algorithm is a finite step-by-step


list of well defined instructions for
solving a particular problem
Complexity of Algorithm

 Itis the function which gives the running


time or space in terms of input size.
 f(x)
 Time Complexity T(n)

 Number of steps require to complete its run for


input size always smaller than T(n).
 n = number of steps
 n < T(n)
Space Complexity
The number of bits required to complete
its run for a input of size n is always <=
s(n)
 Thisboth defines the efficiency of our
algorithm
 Cases – best , worst , averahe
 Three algorithm
 Which is better
Asymptotic notation

Asymptotic means line that tends


to coverage to curve which may
not eventually touch the curve
means
Within the boundary
 Algorithm takes maximum time to run – upper
bound
 Algorithm takes minimum time to run – lower
bound
 T(n)– any value between Upper Bound and Lower
Bound
Three types of Asymptotic Notations

 Big Oh (O) – worst case


 Big Omega (Ω) – Best Case
 Big Theta (Θ) – Average Case
Big Oh

 Running time
 Big Oh says that
 0< =f(n) <= c.g(n) -- 1
 f(n) – larger than n0
c = constant
n > n0
Example
 f(n) = 3n + 2
 g(n) = n
 Then f(n) = O(g(n)) -- 1
 f(n) <= O(g(n))------- 1
 3n + 2 <= c.n
 3n+2 <= 4n n0 > 2
 Constant value = c
 Write and sort an array
 Teacher – executes – on his system – 16 bit computer – is
slow, takes two days.
 Your – system –executes – enough faster – within a second.
 C-- how much time PC takes to run that program
 C – constant for every unique PC
 If time takes O(n) , then multiply by C
 Thisindicates in this PC, this algorithm takes this
time ---c.O(n).
C – Vary
 Big Oh --- upper bound
 Algorithm takes O(n) – maximum time
 Minimum time is not known
 Not much important

You might also like