数据结构笔记-构造次优查找树

//构造次优查找树

void secondOptmal(BiTree &T, Elemtype R[], float sw[], int low, int high)
{
	int i = low, j;
	float min = sw[high] - sw[low];
	float dw = sw[high] + sw[low+1];
	
	for(j=low+1;jdata = R[i];
	if(i == low)
		T->lchild = NULL;
	else
		sencondOptimal(T->lchild, R, sw, low, i-1);//构造左子树
	
	if(i == high)
		T->rchild = NULL;
	else
		secondOptimal(T->rchild, R, sw, i+1, high);//构造右子树
}

你可能感兴趣的:(算法,数据结构)