On 8/24/06, Joe <[EMAIL PROTECTED]> wrote: > > Hi, > In a sequence o,f from 1 to n (1,2,3,...n) numbers, we need to find the > missing numbers. There will not be duplicates. > Can you please suggest an algorithm. > Thanks, > Joe.
Here is linear time algorithm with O(n) memory. bool set[MAXN]; for i=1..m do set[ sequence[i] ] = true for i=1..n do if (set[i] == false) print i; I think you can not improve running time but maybe it is possible to solve this problem in O(1) memory. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---