@Devi;
Consider this,
N = 2
The array elements should these (N+2), numbers : {1, 2, 3, 4}
If the given array is {4, 3}
Will your code work correctly?

2009/7/31 Devi G <[email protected]>

> The logic is actually simple. Tot if we mark in some way an element when
> it's scanned, we can find the missing numbers in the second scannin.
>
> 3,5,1,2,9,10,8,6
>
> When for loop sees '3' it knows elt 3 is there. So multiplies the number at
> 3rd position by some arbitrary number. (* I've taken the arbitrary number
> to be n here but CORRECT ONE IS n+3 cos n will fail in some cases*)
>
> so, when it sees '5' multiplies the number at 5th position by n+3.
> It skips when the numbr is greater than n.
>
> n+3 = 11 here.
>
> So,after first loop,
> 33, 55, 11, 2 , 99, 110, 8, 66.
>
> So now, in the second scan, the indices of all elts that are divisible by
> n+3 are present in the array.
> elts at 4th and 7th positions are not divisible. hence missing numbers are
> 4 and 7.
>
>
>
> >
>


-- 
"Reduce, Reuse and Recycle"
Regards,
Vivek.S

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to