It is a bit tricky without using external memory .It is like insertion sort.
correct me if i am wrong.
for(i=n;i<2*n;i++)
{
x=a[i];
for(j=i-1;;j--)
{
if(j==0 || a[j-1]=='c') // 'c' indicates some character you can
check its ascii value
break;
a[j+1]=a[j];
}
a[j+1]=x;
}
On 1 August 2011 10:02, kumar raja <[email protected]> wrote:
> It is a bit tricky without using external memory
> correct me if i am wrong.
>
> for(i=n;i<2*n;i++)
> {
>
>
>
> On 1 August 2011 02:42, shady <[email protected]> wrote:
>
>> when was this question asked in Google ? approximate date ? position ?
>>
>>
>> On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta <[email protected]>wrote:
>>
>>> A is an array of size 2n such that first n elements are integers in any
>>> order and last n elements are characters.
>>> i.e. A={i1 i2 i3 ....in c1 c2 c3... cn}
>>> then we have to rearrange the elements such that final array is
>>> A ={ i1 c1 i2 c2 ...... in cn}
>>>
>>>
>>> Example :
>>> input : A ={ 5,1,4,d,r,a};
>>> output : A= {5,d,1,r,4,a};
>>>
>>> --
>>> Abhishek Gupta
>>> MCA
>>> NIT Calicut
>>> Kerela
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> Regards
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> [email protected]
> 7797137043.
> 09491690115.
>
>
--
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
[email protected]
7797137043.
09491690115.
--
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.