[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Idris
Also I think more emphasis should be given to Logic and algo not, test cases here..:-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@google

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Idris
Thats the reason I said... pls work around the solution for perfect output:-) I dint spend much time on coding --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To po

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Ksitami
Hi Idris, 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 8 hi this is the answer? What about double 8 on the end? Try to rewrite program this way: #define N 16 int a=[N+1]; for (i=0, i<=N; i++) a[i]=i; Easier to experiment with different N. Correct solution: 1 3 5 7 2 4 6 8 odd fi

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Idris
FIRST PLS pls rate 5 star to my post:-) --* * * * *-- let me know in case u have doubt... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To pos

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Idris
HERE IS THE MAGIC DICE #include main(){ //{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} int i,a[]={0,1,1,2,2,3,3,4,4,5,5, 6, 6, 7, 7, 8, 8}; //ARRAY OF LENGTH 16+1 int count,temp,value_of_i,m=0; for(i=0;i<16;i++) printf("%d ",i); printf("\n");

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Ksitami
MAGIC ;-) I don't now N | i (same for N+1) +--- 3 | 1 5 | 1 7 | 1 3 9 | 1 3 11 | 1 13 | 1 15 | 1 3 5 7 17 | 1 3 19 | 1 21 | 1 3 5 7 9 23 | 1 5 25 | 1 5 27 | 1 3 9 29 | 1 31 | 1 3 5 7 11 15 33 | 1

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Idris
#include main(){ //{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} int i,a[]={0,1,1,2,2,3,3,4,4,5,5, 6, 6, 7, 7, 8, 8}; int count,temp,value_of_i,m=0; for(i=0;i<16;i++) printf("%d ",i); printf("\n"); for(i=0;i<16;i++)

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-16 Thread Vikram Venkatesan
Hi Ksitami, In the first algorithm, what if the CYLCE OF REPLACEMENTS sorts the whole array(I mean, all the elements are visited during the 1st iteration itself, thus creating a COMPLETE CYCLE of the array, putting it in the right order), and the array gets to the FINAL position (i.e. a1a2...b1

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-15 Thread Ksitami
Idris napisał(a): > How about using 1 variable o(1) Space.. > > i.e Scan the array and compare the element... at a[1]=a1, a[2]=b1, > a[3]=a2,.. > > first check(a[i]), say b2 in array of size 8, so Its clear b2 must be > placed at 8/2+2 position in an array.. "012345678" => "024681357" .--

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-15 Thread Idris
How about using 1 variable o(1) Space.. i.e Scan the array and compare the element... at a[1]=a1, a[2]=b1, a[3]=a2,.. first check(a[i]), say b2 in array of size 8, so Its clear b2 must be placed at 8/2+2 position in an array.. so Space=a[8/2+2] a[8/2+2]=b2, the actual place of b2 now a[

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-14 Thread gingernut
Hi, I this might work a1,b1,a2,b2,a3,b3,a4,b4,a5,b5 swap the elements in pairs starting from the second elementtraversing from the left to right the first 'b' element i.e a1-(a2,b1)-(a3,b2)-(a4,b3)-(a5,b4)-b5 do it again starting from b1 a1,a2-(a3,b1)-(a4,b2)-(a5,b3)-b4,b5 a1,a2,a3-(a4,b1)

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-14 Thread amit
If the problem is always to follow the same pattern as in the above question, ie some [a] and [b] constant strings and after the strings it is always an arithmetic progression like 1,2,3... then the problem is still simple. We can have one parse which would tell us the last two patterns say anbn o

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-14 Thread arun kumar manickan
interesting solution really.   but the order of the algorithm seems to be n^2 / 4 . [ as we will look at n/2 elements each time and swap them, and repeating this for n/2 times ]   please correct me if I am wrong.   thanks. --~--~-~--~~~---~--~~  You received this me

[algogeeks] Re: Arranging arrays in to two sets.

2006-11-14 Thread Arun
an ineffcient O(nlgn) solution is possible with sorting where the comparision function isa[i] < a[j] where i < j b[i] < b[j] where i < j and  a[n] < b[1]im sure theres a O(n) solution, but cudnt think of it right-away continously swaping(i.e start with b1 , put in the desired place X, put element o