I'm sorry...... misunderstood the problem and tot the missin numbers are to be less than n. Yet it can be modified to suit the pbm.
Suppose the two missin numbers are greater than n, then m==0 when exitin the loop. So they will be n+1 and n+2 only. in case, one of the missin numbers is greater than n, then m==1, and can be simply found by subtracting the (array_sum+x[0] ) from (sumof 1 to n+2) numbers. On Thu, Jul 30, 2009 at 10:55 PM, Devi G <devs...@gmail.com> wrote: > for(i=1; i<=n ;i++ ) //for ease of understanding starting the > array with 1. > { > if(a[ i ] > n ) > continue; > else > a[ a [ i ] ]*=n; > } > > int x[2], m = 0; > > for ( int i = 1; i <=n ; i++) > { > if(a[ i ] % n == 0) > continue; > else > { > x[m++ ] = i; > if(m == 2) break; > } > } > > x[] now contain the two missing numbers in ascending order. > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---