I don't think so. Try it on {2, 5, 1, 7} and {5, 7, 1, 2}

-- 


On Wed, Jul 27, 2011 at 10:33 AM, Sonal Maheshwari <[email protected]>wrote:

> i think the following shud work:
>
> i=j=0;
> while(i< n && j<n) // n is the number of elements in the array
> {
>       if ( a[i] < b[j] )
>       {
>               pos= find(b, a[i]); ///find the position of a[i] in
> array b
>               swap ( b[j], b[pos] ); //swapping the two numbers
>       }
>       else if ( a[i] > b[j] )
>       {
>               pos= find(a, b[j]); ///find the position of b[j] in
> array a
>               swap ( a[i], a[pos] ); //swapping the two numbers
>       }
>       i++;
>       j++;
> }
>
> Correct me if m wrong...
>
> On Jul 27, 8:46 am, siva viknesh <[email protected]> wrote:
> > Given two arrays
> > a[] = {1,3,2,4}
> > b[] = {4,2,3,1}
> > both will have the same numbers but in different combination.
> > We have to sort them . The condition is that you cannot compare only
> > elements within the same array.You can compare element of one array
> > with
> > another only.
> >
> > On Jul 27, 8:45 am, sivaviknesh s <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > ---------- Forwarded message ----------
> > > From: Padmaja Sridharan <[email protected]>
> > > Date: Wed, Jul 27, 2011 at 5:15 AM
> > > Subject: SORTING ARRAYS
> > > To: [email protected]
> >
> > > Given two arrays
> > > a[] = {1,3,2,4}
> > > b[] = {4,2,3,1}
> > > both will have the same numbers but in different combination.
> > > We have to sort them . The condition is that you cannot compare only
> > > elements within the same array.You can compare element of one array
> with
> > > another only.
> >
> > > ~With Regards
> > > Padmaja
> >
> > > --
> > > Regards,
> > > $iva
>
> --
> 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?hl=en.
>
>

-- 
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?hl=en.

Reply via email to