kumar wrote:
> kerry wrote:
>
> > need O(n) time
> > the array is set[n],
> > for(i = 1, i <=n ; i++)
> >      if((set[i] & 1) & (set[i + 1] & 1))
> >         then miss the number i+1;
>
> ur logic is not satisfied for even the array is in sorted order also.
> For sorted array
>  we need ( set [ i ] & 1) & ( set [ i + 1 ] & 1) | |  ( set [ i ] & 0 )
> & ( set [ i + 1 ] & 0 )
> then only ur logic is applicable
>
> Check it once.
> If it satisfies give one example to understand code clearly.

even now, it won't work if two consecutive numbers are skipped.

By the way: you can 'sort' the numbers into an array if you have lots
of memory and the array subscription is cheap to do,  just put number i
into ith position.
use the algorithms mentioned before in this thread


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to