Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4009.00元

左右斜树

满二叉数

完全二叉树

 子:2i 2i-1

父:i/2

不存在也编号

顺序存储一般用于完全二叉树

二叉链表

lchild data rchild

内存高,无法访问父结点

[展开全文]
simulacra · 2022-05-09 · 0
 int m;
 int[] w ={0,3,4,5};
 int[] p = {0,4,5,6};
 
 static void int Exhaustivity(int m,int[] w,int[] p)
{
   
}

 

[展开全文]
gaoziYY · 2020-12-16 · 0

分治算法—最大子数组问题

 

[展开全文]
鲁鲁 · 2020-11-02 · 0
  1. 二叉树的遍历
  2. 佛挡杀佛打发似的
[展开全文]
yangyu20121220 · 2017-09-06 · 0

struct SubArray

{

public int startIndex;

public int endIndex;

int total;

}

 

static SubArray GetMaxSubArray(int low, int high, int[] array)

{

if(low == high)

{

SubArray subarray;

subarray.startIndex = low;

subarray.endIndex = high;

subarray.total = array[low];

return subarray;

}

 

SubArray subArray1 = GetMaxSubArray(low,mid,array);

SubArray subArray2 = GetMaxSubArray(mid+1,high,array);

//从[low,mid] 找到最大子数组[i,mid]

int total1 = array[mid];

int startIndex = mid;

int totalTemp = 0;

for(int i = mid;i >= low; --i)

{

totalTemp += array[i];

if(totalTemp > total1)

{

total1 = totalTemp;

startIndex = i;

}

}

//从[mid+1,high]找到最大子数组[mid+1,j]

int total2 = array[mid+1];

int endIndex = mid+1;

totalTemp = 0;

for(int j = mid+1;j <= high; ++j)

{

totalTemp += array[j];

if(totalTemp > total2)

{

total2 = totalTemp;

endIndex = j;

}

}

SubArray subArray3;

subArray3.StartIndex = startIndex;

subArray3.EndIndex = endIndex;

subArray3.total = total1+total2;

if(subArray1.total >= subArray2.total && subArray1.total >= subArray3.total)

{

return subArray1;

}else if(subArray2.total >= subArray1.total && subArray2.total >= subArray3.total)

{

return subArray2;

}

else {

return subArray3;

}

 

}

[展开全文]
随风而逝 · 2017-08-28 · 0

这里算法。感觉可以写这样

for(int i = 0 ;i < len ; ++i)

{

int temp = 0;

for(int j = i; j < len; ++j)

{

temp += array[j];

if(temp > total)

{

total = temp;

startIdx = i;

endIdx = j;

}

}

}

[展开全文]
随风而逝 · 2017-08-23 · 0

分治法显示股票的价格波动解决了一个很有趣的问题--如何在哪天买入哪天卖出可以获得最大收益。

1.通过得到一个价格变动的数组中的子数组。(最大的和)则能确定哪天买入卖出收益最大。则将收益问题转换为最大子数组问题。

 

[展开全文]
随风而逝 · 2017-08-23 · 0