if we have 1 2 5 7 3 4 6
can you explain how to do in place merge... the elements are in an array
?
On Sun, Jul 11, 2010 at 10:29 AM, jalaj jaiswal
wrote:
> its easy
> suppose the array is 12345 4321 2345 4321
> it increases then dcreases then increases and decreases again
>
> fi
its easy
suppose the array is 12345 4321 2345 4321
it increases then dcreases then increases and decreases again
first of all in a single scan find the location of decreasing sub-arrays
here it is 5 to 8 and 13-16
and reverse the decreasing array.
so the array becomes
12345 1234 2345 1234
now do
thr is no search option there ..
if u can gimme the link that will be good ..
--
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 this group, send email to
algo
this is called k-toinc sorting...solution is very easy for this..you can
check topcoder forum
On Sun, Jul 11, 2010 at 6:43 AM, srikanth sg wrote:
> Given an array of size n wherein elements keep on increasing
> monotically upto a certain location
> after which they keep on decreasing monotically,
Given an array of size n wherein elements keep on increasing
monotically upto a certain location
after which they keep on decreasing monotically, then again keep on
increasing, then decreasing
again and so on. Sort the array in place (ie. using only O(1) extra
memory).
--
You received this messag
left child=2*i+1,right child=2*i+2,parent=(i-1)2
#include
using namespace std;
void sort(int );
int a[]={100,50,150,25,75,125,200};
int main(){
sort(0);
system("pause");
return 0;
}
void sort(int i){
int n=7;
if(i>=0&&i<=n-1){
sort(2*i+1);
Given a complete binary search tree in form of array. Write a sort function
to sort the given array in O(n)time complexity and constant memory.
say the tree is
100
_50___150
___25___75__125___200
then array is {100 50 150 25 75 125 200}
you need to sort the array.
--
You receiv