left child=2*i+1,right child=2*i+2,parent=(i-1)2
#include<iostream>
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);
                        cout<<a[i]<<" ";
                        sort(2*i+2);
       }
}






On Mon, Jun 28, 2010 at 1:30 AM, sharad kumar <sharad20073...@gmail.com>wrote:

> 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 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
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to