Introduction to Complexity in Data Structure by R4R Team

Algorithmic complexity is concerned about how fast or slow particular algorithm performs. We define complexity as a numerical function T(n) - time versus the input size n. We want to define time taken by an algorithm without depending on the implementation details. But you agree that T(n) does depend on the implementation! A given algorithm will take different amounts of time on the same inputs depending on such factors as: processor speed; instruction set, disk speed, brand of compiler and etc. The way around is to estimate efficiency of each algorithm asymptotically. We will measure time T(n) as the number of elementary "steps" (defined in any way), provided each such step takes constant time.

Types of Complexity :
Space Complexity: Total Physical space taken by the algorithms to run in memory.
Time Complexity : Total time taken by the algorithms to run.

Basically, We do not focus more on space complexity because in real world we have infinite space to store data but it is also important to run a algorithms to run in minimum space because space also impact on time when we search data in memory.

Time Complexity:
Time take by algorithm at run time is may be differ algorithm to algorithm.
It may be possible that some algorithms are run faster then other algorithm.
Basically, Time complexity are also depends on type of input value.
worst case time complexity
average case time complexity
best case time complexity

All above case may be get by one algorithm on different input data's

Operation that perform in unit time i.e., O(1):
int i=10

Operation that perform in O(n) time:
while(i< n)
for(i=0;i< n;i++)

Operation that perform in O(n^2) time:
while(i< n)
while(j< n){

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!