#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 1001;
int n;
int indexn[maxn],cbt[maxn],ind = 0;
void inO(int root)
{
if(root > n) return;
inO(root * 2);
cbt[root] = indexn[ind++];
inO(root * 2 + 1);
}
int main()
{
// freopen("1.txt","r",stdin);
scanf("%d",&n);
for(int i = 0;i<n;i++)
{
scanf("%d",&indexn[i]);
}
sort(indexn,indexn+n);
inO(1);
for(int i = 1;i<=n;i++)
{
printf("%d",cbt[i]);
if(i!=n)
printf(" ");
}
return 0;
}
1064 Complete Binary Search Tree (30 分)(******)
最新推荐文章于 2024-08-17 18:02:02 发布