Re: [algogeeks] Re: sort in O(n) array which increases and then decreased and then increases...5,10,15,14,9,4,1,3,6,7,11,9,8,2

2010-07-15 Thread jalaj jaiswal
try merging this array [{5,9,10},{3,6,7,9}]... On Wed, Jul 14, 2010 at 9:30 AM, Ashish Goel ashg...@gmail.com wrote: int dstart = -1; int dend = -1; int istart=-1; int iend = -1; bool decreasing = false; for (int i=1;in;i++) { if (a[i] =a[i-1]) { if (decreasing) { dend

Re: [algogeeks] Re: sort in O(n) array which increases and then decreased and then increases...5,10,15,14,9,4,1,3,6,7,11,9,8,2

2010-07-15 Thread Ashish Goel
good one shifting array is the solution but i want to do it without shifting, is there a solution!!! Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Thu, Jul 15, 2010 at 4:26 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: try merging this

Re: [algogeeks] Re: sort in O(n) array which increases and then decreased and then increases...5,10,15,14,9,4,1,3,6,7,11,9,8,2

2010-07-13 Thread Ashish Goel
int dstart = -1; int dend = -1; int istart=-1; int iend = -1; bool decreasing = false; for (int i=1;in;i++) { if (a[i] =a[i-1]) { if (decreasing) { dend =i-1; istart=i; reverse (a, dstart, dend); merge(a,0,dstart-1, dstart, dend); ///merge 0, dstart-1 array with array

[algogeeks] Re: sort in O(n)

2010-07-12 Thread Tech Id
This is a good solution. Reversing the arrays will be O(n) Then merging will be O(n) too. In place merge is something like this. Have two indices as start1 and start2 start1 points to beginning of mini-sorted portion1 start2 points to beginning of mini-sorted portion2 Increase both start1 and

Re: [algogeeks] Re: sort in O(n)

2010-07-12 Thread Amit Jaspal
@ above can u please be more specific let A[1,9,10] and B [2,4,6] Now how to swap so that the complexity remains O(n) -- Forwarded message -- From: Tech Id tech.login@gmail.com Date: Mon, Jul 12, 2010 at 8:18 PM Subject: [algogeeks] Re: sort in O(n) To: Algorithm Geeks

Re: [algogeeks] Re: sort in O(n)

2010-07-12 Thread Anand
how to swap so that the complexity remains O(n) -- Forwarded message -- From: Tech Id tech.login@gmail.com Date: Mon, Jul 12, 2010 at 8:18 PM Subject: [algogeeks] Re: sort in O(n) To: Algorithm Geeks algogeeks@googlegroups.com This is a good solution. Reversing

Re: [algogeeks] Re: sort in O(n)

2010-07-12 Thread srikanth sg
:18 PM Subject: [algogeeks] Re: sort in O(n) To: Algorithm Geeks algogeeks@googlegroups.com This is a good solution. Reversing the arrays will be O(n) Then merging will be O(n) too. In place merge is something like this. Have two indices as start1 and start2 start1 points to beginning

Re: [algogeeks] Re: sort in O(n)

2010-07-12 Thread Anand
...@gmail.comwrote: @ above can u please be more specific let A[1,9,10] and B [2,4,6] Now how to swap so that the complexity remains O(n) -- Forwarded message -- From: Tech Id tech.login@gmail.com Date: Mon, Jul 12, 2010 at 8:18 PM Subject: [algogeeks] Re: sort in O(n

Re: [algogeeks] Re: sort in O(n)

2010-07-12 Thread jalaj jaiswal
] Re: sort in O(n) To: Algorithm Geeks algogeeks@googlegroups.com This is a good solution. Reversing the arrays will be O(n) Then merging will be O(n) too. In place merge is something like this. Have two indices as start1 and start2 start1 points to beginning of mini-sorted portion1 start2

[algogeeks] Re: sort in O(n)

2010-07-12 Thread Gene
On Jul 12, 10:48 am, Tech Id tech.login@gmail.com wrote: This is a good solution. Reversing the arrays will be O(n) Then merging will be O(n) too. In place merge is something like this. Have two indices as start1 and start2 start1 points to beginning of mini-sorted portion1 start2

[algogeeks] Re: sort in O(n)

2010-07-11 Thread Tech Id
I searched Google for it but no luck. Texts have made references to k-tonic sort but couldn't find definition. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from