锦标赛算法_找第一名和第二名

//

满二叉树:
( node_sum=2^layor-1 ) ( dad_pos=(x_pos-1)/2 )
0 (1=2^1-1)
1 2 (3=2^2-1) (1-1)/2=0
3 4 5 6 (7=2^3-1) (3-1)/2=1 (5-1)/2=2
...
( left_child_pos=2*dad_pos+1 )
( right_child_pos=left_child_pos+1 )

//
#include
using namespace std;

const int N=1e5+6;
int a[N];

// a[] 起始数据
// b[] 起始数据对应的下标 -1 表示为空

void f2( int a[],int b[],int b_size,int k,int first )
{
int k1=2*k+1,k2=k1+1; // k的 左节点 右节点

锦标赛算法_找第一名和第二名最先出现在Python成神之路

版权声明:
作者:倾城
链接:https://www.techfm.club/p/25400.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>