Presentation is loading. Please wait.

Presentation is loading. Please wait.

A priority queue for small integers. 1st Step: Prove this Priority queue capacity: n (w / logn loglogn)-bit keys insert, find-min, delete-min: constant.

Similar presentations


Presentation on theme: "A priority queue for small integers. 1st Step: Prove this Priority queue capacity: n (w / logn loglogn)-bit keys insert, find-min, delete-min: constant."— Presentation transcript:

1 A priority queue for small integers

2 1st Step: Prove this Priority queue capacity: n (w / logn loglogn)-bit keys insert, find-min, delete-min: constant time space: O(n)

3 Preliminary lemmas(1) 3175 4286 21436587 O(log k) 1 word 2 words 109 121113 21436587 O(n/k . log k) 3175 4286 109121113 O(log k)

4 Preliminary lemmas(2) Priority queue capacity: O(k) (w / k)-bit keys insert, find-min, delete-min: constant time delete: constant amortized time

5 B1B1 B2B2 Amortized bounds: Structure buffers R M 3.4 priority queue capacity: k keys 3.4 priority queue B0B0 B log(n/k) ......

6 Amortized bounds: Notes

7 B1B1 B2B2 Amortized bounds: insert (w/o delete-min) R M B0B0 B log(n/k) ...... 3 1 7 5 4286 find-min, delete-min O(1) per key O(1 / logn) per key 1 delete, (insert) O(1) per key insert O(1) 12834567

8 B1B1 B2B2 Amortized bounds: insert (w/ delete-min) R M B0B0 B log(n/k) ...... 981110 214365307 13121514982143657 30 10 1 8 81312111091514910111213301514 10

9 R’’’ R’’ B1B1 B2B2 Worst-case insertions: Structure R’ 3.4 priority queue capacity: k keys B0B0 B log(n/k) ...... A sorted list Contains k keys in 1 word M

10 Worst-case insertions: Notes

11 R’’ B1B1 B2B2 Worst-case insertions: Part 1 R’ B0B0 B log(n/k) ...... R’’’ M 3 7 5 1 3 7 5 1 8 6 4 2 8 6 4 2 find-min, delete-min O(1)

12 R’’ B1B1 B2B2 Worst-case insertions(2) Part 2 R’ B0B0 B log(n/k) ...... M R’’’ 7531 2021222327262524 8642 k / logn steps ......

13 No overloading: w/o delete-min

14 7531 No overloading: w/ delete-min delete-min –If minimum key μ in R’, R’’ → delete-min –If μ in R’’’ → delete the first –If μ in B i → min-pointer 1 8642 M 12 6866646267656361 ... BiBi

15 Deletions from M MM’ 86427531 11 18161412171513116866646267656361 1 12 2 ... BiBi BjBj delete-min, insert O(1) Total cost = O(log n) ......

16 Priority queues for arbitrary integers

17 Next Step DONE! Q Priority queue find-min : constant time insert, delete-min: O(loglog n) time

18 Q 15 8 254 119 323 28 151 54 23 Insert 54 19 ∞1

19 Q 15 8 1 3 2 23 Delete-min 54 19 1 2

20 Pseudo Code Recursive

21 Analysis 2w-bit keys –Recursive log(2 logn loglogn) = O(loglogn) times to reduce to (w / logn loglogn)-bit keys –Total time = O(loglogn)


Download ppt "A priority queue for small integers. 1st Step: Prove this Priority queue capacity: n (w / logn loglogn)-bit keys insert, find-min, delete-min: constant."

Similar presentations


Ads by Google