View
15
Download
0
Category
Preview:
DESCRIPTION
15.082 and 6.855J February 25, 2003. Radix Heap Animation. . . 5. 2. 4. 15. 2. 13. 0. . 1. 6. 20. 0. 8. 9. 3. 5. . . . An Example from AMO (with a small change). Initialize distance labels. Initialize buckets and their ranges. Insert nodes into buckets. 2 3. - PowerPoint PPT Presentation
Citation preview
1
15.082 and 6.855J February 25, 2003
Radix Heap Animation
2
An Example from AMO (with a small change)
1
0 1 2
3
47
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Initialize distance labels
Insert nodes into buckets.
Initialize buckets and their ranges.
0
23456
3
Select
1
0 1 2
3
47
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Select the node with minimum distance label
0
23456
1
4
Update
3
0 1 2
3
47
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Scan arcs out of node 1 and update distance labels.
0
23456
1
13
2
0
15
4
20
5
5
Select
3
0 1 2
3
47
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Select the node with minimum distance label 0
6
1
24
5
Node 3 has label 0, which is minimum.
13
0
15
20
3
6
Update
3
0 1 2
3
47
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Scan arcs out of node 3 and update distance labels.
0
6
1
24
5
13
0
15
20
3
9
5
7
Select: part 1
0 1 2
3
47
8 15
16 31
3263
1
2 4
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
24
13
0
15
20
3
9
5
8
Select: part 2
0 1 2
3
47
8 15
16 31
3263
1
2 4
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
24
13
0
15
20
3
9
5
d(5) = 9, which is minimum.
9
Select: part 3
0 1 2
3
8 15
16 31
3263
1
2 4
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
24
13
0
15
20
3
9
5
9 10 11 12
471315
10
Select: part 4
0 1 2
3
1315
8 15
16 31
3263
1
2 4
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
24
13
0
15
20
3
9
5
9 10 11 12
425
At this point the leftmost bucket is non-empty
11
Select: part 5
0 1 2
3
1315
8 15
16 31
3263
1
2 4
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
9 10 11 12
425
5
12
Update
0 1 2
3
1315
8 15
16 31
3263
1
2 4
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
9 10 11 12
42
5
17
6
Reinsert nodes in correct buckets by scanning left.
13
Select: parts 1 and 2
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Find the minimum non-empty bucket.
01
13
0
15
20
3
9
9 10 11 12
42
5
17
6
Find the minimum distance label in the bucket
14
Select: parts 3 and 4
0 1 2
3
1315
8 15
16 31
3263
1
2 4
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
9 10 11 12
42
5
17
6
Reinsert nodes in correct buckets.
13 14 15
2 4
15
Select: part 5
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Select a node from the leftmost bucket.
01
13
0
15
20
3
9
9 10 11 12
5
17
6
13 14 15
2 4
2
16
Update
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Scan the arc out of node 2.
01
13
0
15
20
3
9
9 10 11 12
5
17
6
13 14 15
4
2
17
Select, Modified rule 1
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Find the minimum non-empty bucket
01
13
0
15
20
3
9
9 10 11 12
5
17
6
13 14 15
4
2
If the bucket has a width of 1, select any node in the bucket.
4
18
Update
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Scan the arc out of node 4
01
13
0
15
20
3
9
9 10 11 12
5
17
6
13 14 15
2 4
19
Select: modified rule 2
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
Find the minimum non-empty bucket
01
13
0
15
20
3
9
9 10 11 12
5
17
6
13 14 15
2 4
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
The algorithm ends
0 1 2
3
1315
8 15
16 31
3263
1
2 4
53
6
13
5
2
8
15
20
9
0
There are no arcs to update.
01
13
0
15
20
3
9
9 10 11 12
5
17
13 14 15
2 4
There are no nodes that need to be permanently labeled.
6
Recommended