Analysis of Recursive and Non Recursive Algorithms

Before understanding the non-recursive algo technique need to know about leader of array, that states like this : An element in an array is called leader if it is greater than all the elements to the right of it. The time complexity of the most efficient algorithm to print all the leaders of an array size n is O(n).

Algorithm design(A,n){

L = A(n);

for i← (n -1) to 1

if(A[i] > L)

{

print A[i];

L = A[i];

}

}

--

--

Devaraj Chennur

My name is Devaraj, working with Java framework at CTS ( Developer).