ur Algo-2 is totaly wrong because 1>any array should have atleast size 1..so ,a[0] is not valid....a[1] is valid... 2>why we should use a,b two different arrays.. just one array is sufficient.. like--int arr[3].. and finally REMEMBER IT THAT TIME COMPLEXITY IS NOT CONCERN ABOUT STORAGE...it is depends upon key operations like-searching...