Monday, 18 September 2017

Time complexity Calculation


A program with time complexity 4n is more complex than the program with time complexity 16*n16
For ex: Let n=1024 =210
4n can be written as  22n
and substituting n value in 22n, we get
22*1024  =22048

and substituting n value in 16*(1024)16, we get
24 *(210)16
= 24 *2160
=2164
Hence for larger values of n, a program with time complexity 4n is more complex than the program with time complexity 16*n16
Time complexity of 4n+16*n16 would be O(22n)



No comments:

Post a Comment