No. of Step Calculation in an Algorithm

There was a time when the processor were just starting to explore their potential. Then code optimization made a huge difference in the performance of the code. But, today most programmers take the optimization for granted as the compilers are smarter and the processors run like they have fire on their ass. But, to be a good programmer, one should always stick to the roots of programming.

Let their be three arrays, A, B and C of equal lengths n. And an operation is to be performed say,

for(i = 0; i < n; i++) A[i] = B[i] + C[i]

Everybody knows that the program is of O(n) complexity. But, what struck me hard is, people say that n statements will be executed for this. This is because, those morons have never been exposed to assembly like programming. This is because of the driver’s mindset, instead of the mechanic’s mindset.

For those who don’t know, your coding language will in turn call the instructions of the processor as: