Download presentation
Presentation is loading. Please wait.
Published byReece Coffin Modified over 9 years ago
1
15.082 and 6.855J February 25, 2003 Radix Heap Animation
2
2 An Example from AMO (with a small change) 1 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Initialize distance labels Insert nodes into buckets. Initialize buckets and their ranges. 0 2 3 4 5 6
3
3 Select 1 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Select the node with minimum distance label 0 2 3 4 5 6 1
4
4 Update 3 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Scan arcs out of node 1 and update distance labels. 0 2 3 4 5 6 1 13 2 0 15 4 20 5
5
5 Select 3 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Select the node with minimum distance label 0 6 1 2 4 5 Node 3 has label 0, which is minimum. 13 0 15 20 3
6
6 Update 3 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Scan arcs out of node 3 and update distance labels. 0 6 1 2 4 5 13 0 15 20 3 9 5
7
7 Select: part 1 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Find the first non-empty bucket, by scanning buckets from left to right. 0 6 1 2 4 13 0 15 20 3 9 5
8
8 Select: part 2 0 1 2323 4747 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Determine the minimum distance value in the bucket, by scanning all nodes in the bucket. 0 6 1 2 4 13 0 15 20 3 9 5 d(5) = 9, which is minimum.
9
9 Select: part 3 0 1 2323 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Redistribute the range of bucket 5 into the first 4 buckets, starting with value 9. Bucket widths stay the same, except that some may be smaller. 0 6 1 2 4 13 0 15 20 3 9 5 910 11 12 4747 13 15
10
10 Select: part 4 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Reinsert nodes in the correct bucket. Determine the bucket by scanning left. 0 6 1 2 4 13 0 15 20 3 9 5 910 11 12 4 2 5 At this point the leftmost bucket is non-empty
11
11 Select: part 5 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Select a node in the leftmost bucket. 0 6 1 13 0 15 20 3 9 910 11 12 4 2 5 5
12
12 Update 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Scan arcs out of node 5 and update distance labels. 0 6 1 13 0 15 20 3 9 910 11 12 4 2 5 17 6 Reinsert nodes in correct buckets by scanning left.
13
13 Select: parts 1 and 2 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Find the minimum non-empty bucket. 0 1 13 0 15 20 3 9 910 11 12 4 2 5 17 6 Find the minimum distance label in the bucket
14
14 Select: parts 3 and 4 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Redistribute bucket ranges in the minimum bucket 0 1 13 0 15 20 3 9 910 11 12 4 2 5 17 6 Reinsert nodes in correct buckets. 1314 15 24
15
Select: part 5 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Select a node from the leftmost bucket. 0 1 13 0 15 20 3 9 910 11 12 5 17 6 1314 15 24 2
16
16 Update 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Scan the arc out of node 2. 0 1 13 0 15 20 3 9 910 11 12 5 17 6 1314 15 4 2
17
17 Select, Modified rule 1 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Find the minimum non-empty bucket 0 1 13 0 15 20 3 9 910 11 12 5 17 6 1314 15 4 2 If the bucket has a width of 1, select any node in the bucket. 4
18
18 Update 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Scan the arc out of node 4 0 1 13 0 15 20 3 9 910 11 12 5 17 6 1314 15 24
19
19 Select: modified rule 2 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 Find the minimum non-empty bucket 0 1 13 0 15 20 3 9 910 11 12 5 17 6 1314 15 24 If the bucket has a single node, then select the node. 6 Modified rules and heuristics often help in practice, but must be used carefully.
20
20 The algorithm ends 0 1 2323 13 15 8 15 16 31 32 63 1 24 53 6 13 5 2 8 15 20 9 0 There are no arcs to update. 0 1 13 0 15 20 3 9 910 11 12 5 17 1314 15 24 There are no nodes that need to be permanently labeled. 6
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.