Selection Trees What are selection trees Complete Each

  • Slides: 9
Download presentation
Selection Trees

Selection Trees

What are selection trees? Complete Each node represents a “match” Winner Loser binary tree

What are selection trees? Complete Each node represents a “match” Winner Loser binary tree Trees

Diagram – max winner tree 9 9 8 9 5 8 7 9 4

Diagram – max winner tree 9 9 8 9 5 8 7 9 4 3 7 5 8 8 5 5 8 4 1 8 5 5 2 4 6 5 6 3 4 8 1 0 9 2 7 0 1 3 3 … … … …

Diagram – max loser tree 4 5 5 7 9 7 9 4 5

Diagram – max loser tree 4 5 5 7 9 7 9 4 5 4 8 5 5 8 4 5 8 5 5 8 4 6 2 7 3 4 3 3 0 3 1 6 0 1 2 1 … … … …

Runtimes Complexities Initialize r = the number of runs = number of leaf nodes

Runtimes Complexities Initialize r = the number of runs = number of leaf nodes r-1 comparison nodes O(r) to initialize r-runs Compare O(1) Remove winner and Replay O(logr) Total Time for n elements O(nlogr)

What’s this good for? External Sorting Package Loading Problem

What’s this good for? External Sorting Package Loading Problem

Truck Loading Problem n parcels from r sources each parcel has a weight and

Truck Loading Problem n parcels from r sources each parcel has a weight and a size minimize the number of trucks

First Fit Packing with Max Winner Tree Use a max winner tree in which

First Fit Packing with Max Winner Tree Use a max winner tree in which n parcels are t trucks One at a time in left to right order Current item is packed in the left-most into which it fits If there is no truck into which it fits, start a new truck

Best Fit Object is packed into the bin with the least unused capacity that

Best Fit Object is packed into the bin with the least unused capacity that is at least the size of the object If conditions are not met, start a new truck