2.4.7

question:

The largest item in a heap must appear in position 1, and the second largest must be in the position 2 or position 3. Give the list of positions in a heap of size 31 where the kth largest (i) can apprar, and (ii) cannot appear, for k = 2, 3, 4 (assuming the values to be distinct).

answer:

第k大的可以出现在 (第log2 k 向下取整) 到 {(第log2 k 向下取整) +  [2^(第log2 k 向下取整)] - 1},(左右闭区间)

猜你喜欢

转载自www.cnblogs.com/w-j-c/p/9135906.html