Algorithm 2.
Reuse-Tree Merging Algorithm (RTMA)
| 1: | Input: stages; maxBSize; ▹maxBSize refers to maxBucketSize |
| 2: | Output: bucketList; |
| 3: | bucketList ← ∅; |
| 4: | rTree G ← ENERATEREUSETREE(stages) |
| 5: | while rTree.height > 2 do |
| 6: | leafsPList ← GENERATELEAFSPARENTLIST(rTree) |
| 7: | newBuckets ← PRUNELEAFLEVEL(rTree, leafsPList, maxBSize) |
| 8: | bucketList ← bucketList ∪ newBuckets |
| 9: | MOVEREUSETREEUP(reuseTree, leafsPList) |
| 10: | while rTree.root.children ≠ ∅ do |
| 11: | bucket ← ∅ |
| 12: | while rTree.root.children ≠ ∅ and bucket.size ≤ maxBSize do |
| 13: | newBucket ← removeFirstChildren(rTreeRoot); |
| 14: | bucketList ← bucketList ∪ bucket |
| 15: | return bucketList |