天池比赛物流比赛_比赛树及其属性

天池比赛物流比赛

比赛树 (Tournament Tree)

Tournament tree is a complete binary tree n external nodes and n-1 internal nodes. The external nodes represent the players and internal nodes represent the winner of the match between the two players.

锦标赛树是n个外部节点和n-1个内部节点的完整二叉树。 外部节点代表玩家,内部节点代表两位玩家之间的比赛获胜者。

竞赛树的属性 (Properties of Tournament Tree)

  1. It is rooted tree i.e. the links in the tree and directed from parents to children and there is a unique element with no parents.

    它是有根的树,即树中的链接,从父母指向孩子,是一个没有父母的独特元素。

  2. The key value of the parent node has less than or equal to that node to general any comparison operators can be used as long as the relative values of parent-child are invariant throughout the tree. The tree is a parent ordering of the keys.

    父节点的键值小于或等于该节点的值,通常,只要父子节点的相对值在整个树中都是不变的,就可以使用任何比较运算符。 树是键的父级排序。

  3. Trees with a number of nodes not a power of 2 contain holes which is general may be anywhere in the tree.

    节点数不为2的幂的树通常包含可能在树中任何位置的Kong。

  4. Tournament tree is a proper generalization of heaps which restrict a node to at most two children.

    锦标赛树是对堆的适当概括,将一个节点限制为最多两个子节点。

  5. The tournament tree is also called selection tree.

    比赛树也称为选择树。

  6. The root of the tournament tree represents overall winner of the tournament.

    比赛树的根表示比赛的整体赢家。

比赛树的类型 (Types of tournament Tree)

There are mainly two type of tournament tree,

锦标赛树主要有两种类型,

  1. Winner tree

    优胜者树

  2. Loser tree

    失败者树

1)优胜者树 (1) Winner tree)

The complete binary tree in which each node represents the smaller or greater of its two children is called a winner tree. The smallest or greater node in the tree is represented by the root of the tree. The winner of the tournament tree is the smallest or greatest n key in all the sequences. It is easy to see that the winner tree can be computed in O(logn) time.

每个节点代表其两个子节点中较小或较大的完整二叉树称为优胜者树。 树中最小或更大的节点由树的根表示。 锦标赛树的赢家是所有序列中最小或最大的n键。 显而易见 ,优胜者树可以在O(logn)时间中计算出来。

Example: Consider some keys 3, 5, 6, 7, 20, 8, 2, 9

示例:考虑一些键3、5、6、7、20、8、2、9

We try to make minimum or maximum winner tree

我们尝试制作最小或最大的赢家树

Winner tree

Winner tree (minimum)

优胜者树(最低)

2)失败者树 (2) Loser Tree)

The complete binary tree for n players in which there are n external nodes and n-1 internal nodes then the tree is called loser tree. The loser of the match is stored in internal nodes of the tree. But in this overall winner of the tournament is stored at tree [0]. The loser is an alternative representation that stores the loser of a match at the corresponding node. An advantage of the loser is that to restructure the tree after a winner tree been output, it is sufficient to examine node on the path from the leaf to the root rather than the sibling of nodes on this path.

n个玩家的完整二叉树,其中有n个外部节点和n-1个内部节点,然后将该树称为失败者树。 比赛失败者存储在树的内部节点中。 但是,在此锦标赛的总冠军中,存储在树[0]上。 失败者是将匹配失败者存储在相应节点的替代表示。 失败者的一个优点是,在输出获胜者树之后重新构建树,只需检查从叶到根的路径上的节点,而不是该路径上节点的同级节点即可。

Example: Consider some keys 10, 2, 7, 6, 5, 9, 12, 1

示例:考虑一些键10、2、7、6、5、9、12、1

Step 1) We will first draw min winner tree for given data.

步骤1)我们将首先绘制给定数据的最小获胜者树。

Loser tree

Step 2) Now we will store losers of the match in each internal nodes.

步骤2)现在,我们将在每个内部节点中存储比赛失败者。

Loser tree 1

比赛树的应用 (Application of Tournament Tree)

  1. It is used for finding the smallest and largest element in the array.

    它用于查找数组中的最小和最大元素。

  2. It is used for sorting purpose.

    它用于排序目的。

  3. Tournament tree may also be used in M-way merges.

    锦标赛树也可以用于M路径合并。

  4. Tournament replacement algorithm selection sort is used to gather the initial run for external sorting algorithms.

    比赛替换算法选择排序用于收集外部排序算法的初始运行。

翻译自: https://www.includehelp.com/algorithms/tournament-tree-and-their-properties.aspx

天池比赛物流比赛

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值