2.4.10

question:

Suppose that we wish to avoid wasting one position in a heap-ordered array pq[], putting the largest value in pq[0], its children in pq[1] and pq[2], and so forth, proceeding in level order. Where are the parents and children of pq[k]?

answer:

子 2k+1, 2k+2

父 (k-1)/2

猜你喜欢

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