Download

Tournament Trees






Advertisement
/ 35 []
Download Presentation
Comments
shona
From:
|  
(1157) |   (0) |   (0)
Views: 195 | Added:
Rate Presentation: 0 0
Description:
Tournament Trees. Winner trees. Loser Trees. Winner Tree – Definition. Complete binary tree with n external nodes and n – 1 internal nodes. External nodes represent tournament players.
Tournament Trees

An Image/Link below is provided (as is) to

Download Policy: Content on the Website is provided to you AS IS for your information and personal use only and may not be sold or licensed nor shared on other sites. SlideServe reserves the right to change this policy at anytime. While downloading, If for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.











- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




Tournament trees l.jpgSlide 1

Tournament Trees

Winner trees.

Loser Trees.

Winner tree definition l.jpgSlide 2

Winner Tree – Definition

Complete binary tree with n external nodes and n – 1 internal nodes.

External nodes represent tournament players.

Each internal node represents a match played between its two children; the winner of the match is stored at the internal node.

Root has overall winner.

Winner tree for 16 players l.jpgSlide 3

player

match node

Winner Tree For 16 Players

Winner tree for 16 players4 l.jpgSlide 4

1

Winner Tree For 16 Players

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Smaller element wins =>min winner tree.

Winner tree for 16 players5 l.jpgSlide 5

1

Winner Tree For 16 Players

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

height is log2 n (excludes player level)

Complexity of initialize l.jpgSlide 6

Complexity Of Initialize

  • O(1)time to play match at each match node.

  • n – 1 match nodes.

  • O(n) time to initialize n-player winner tree.

Winner tree operations l.jpgSlide 7

Winner Tree Operations

  • Initialize

    • O(n) time

  • Get winner

    • O(1) time

  • Replace winner and replay

    • O(log n)time

    • More preciselyTheta(log n)

  • Tie breaker (player on left wins in case of a tie).

Replace winner and replay l.jpgSlide 8

1

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Replace Winner And Replay

Replace winner with 6.

Replace winner and replay9 l.jpgSlide 9

1

Replace Winner And Replay

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

6

5

7

3

2

6

9

4

5

2

5

8

Replay matches on path to root.

Replace winner and replay10 l.jpgSlide 10

1

Replace Winner And Replay

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

6

5

7

3

2

6

9

4

5

2

5

8

Replay matches on path to root.

Replace winner and replay11 l.jpgSlide 11

1

Replace Winner And Replay

1

2

3

1

2

2

3

6

1

3

2

4

2

5

4

3

6

8

6

5

7

3

2

6

9

4

5

2

5

8

Opponent is player who lost last match played at this node.

Loser tree l.jpgSlide 12

Loser Tree

Each match node stores the match loser rather than the match winner.

Min loser tree for 16 players l.jpgSlide 13

Min Loser Tree For 16 Players

3

4

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players14 l.jpgSlide 14

Min Loser Tree For 16 Players

3

6

1

4

8

5

7

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players15 l.jpgSlide 15

1

Min Loser Tree For 16 Players

3

6

3

2

4

8

5

7

6

9

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players16 l.jpgSlide 16

1

Min Loser Tree For 16 Players

3

2

6

3

4

2

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players17 l.jpgSlide 17

1

Min Loser Tree For 16 Players

3

2

6

3

4

5

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players18 l.jpgSlide 18

1

Min Loser Tree For 16 Players

3

2

6

3

4

5

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Min loser tree for 16 players19 l.jpgSlide 19

2

Min Loser Tree For 16 Players

3

2

6

3

4

5

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Slide20 l.jpgSlide 20

Winner

1

2

3

2

6

3

4

5

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Complexity of loser tree initialize l.jpgSlide 21

Complexity Of Loser Tree Initialize

  • Start with 2 credits at each node.

  • Use one to pay for the match played at that node.

  • Use the other to pay for the store of a left child winner.

  • Total time is O(n).

  • More preciselyTheta(n).

Slide22 l.jpgSlide 22

2

3

5

9

3

1

2

3

2

6

3

4

5

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

9

Winner

Replace winner with 9 and replay matches.

Complexity of replay l.jpgSlide 23

Complexity Of Replay

  • One match at each level that has a match node.

  • O(log n)

  • More preciselyTheta(log n).

Tournament tree applications l.jpgSlide 24

Tournament Tree Applications

  • Run generation.

  • k-way merging of runs during an external merge sort.

  • Truck loading.

Truck loading l.jpgSlide 25

Truck Loading

  • n packages to be loaded into trucks

  • each package has a weight

  • each truck has a capacity of c tons

  • minimize number of trucks

Bin packing l.jpgSlide 26

Bin Packing

  • n items to be packed into bins

  • each item has a size

  • each bin has a capacity of c tons

  • minimize number of bins

Bin packing27 l.jpgSlide 27

Bin Packing

Truck loading is same as bin packing.

Truck is a bin that is to be packed (loaded).

Package is an item/element.

Bin packing to minimize number of bins is NP-hard.

Several fast heuristics have been proposed.

Bin packing heuristics l.jpgSlide 28

Bin Packing Heuristics

  • First Fit.

    • Bins are arranged in left to right order.

    • Items are packed one at a time in given order.

    • Current item is packed into leftmost bin into which it fits.

    • If there is no bin into which current item fits, start a new bin.

Bin packing heuristics29 l.jpgSlide 29

Bin Packing Heuristics

  • First Fit Decreasing.

    • Items are sorted into decreasing order.

    • Then first fit is applied.

Bin packing heuristics30 l.jpgSlide 30

Bin Packing Heuristics

  • Best Fit.

    • Items are packed one at a time in given order.

    • To determine the bin for an item, first determine setSofbins into which the item fits.

    • If S is empty, then start a new bin and put item into this new bin.

    • Otherwise, pack into bin ofSthat has least available capacity.

Bin packing heuristics31 l.jpgSlide 31

Bin Packing Heuristics

  • Best Fit Decreasing.

    • Items are sorted into decreasing order.

    • Then best fit is applied.

Performance l.jpgSlide 32

Performance

  • For first fit and best fit:

    Heuristic Bins <= (17/10)(Minimum Bins) + 2

  • For first fit decreasing and best fit decreasing:

    Heuristic Bins <= (11/9)(Minimum Bins) + 4

Max winner tree for 16 bins l.jpgSlide 33

9

8

9

8

7

9

8

4

8

5

7

6

9

5

8

4

3

6

8

1

5

7

3

2

6

9

4

5

2

5

8

Max Winner-Tree For 16 Bins

Item size = 7

Max winner tree for 16 bins34 l.jpgSlide 34

9

Max Winner-Tree For 16 Bins

7

9

6

7

9

8

4

6

5

7

6

9

5

8

4

3

6

1

1

5

7

3

2

6

9

4

5

2

5

8

Complexity of first fit l.jpgSlide 35

Complexity Of First Fit

O(n log n), where n is the number of items.


Copyright © 2014 SlideServe. All rights reserved | Powered By DigitalOfficePro