Loser tree in Python | Christan Christens 【python|Loser tree in Python | Christan Christens】Loser tree in Python | Christan Christens
Loser tree in PythonI am taking an Advanced Data Structures and Algorithms class with Dr. Sahni at UF. I used a data structure discussed in this class as an opportunity to learn Python a little better. I implemented the loser tree. The loser tree is a complete binary tree with n external nodes and n-1 internal nodes. The root of the tree has the overall winner. The loser tree is a more efficient version of a winner tree which are both types of Tournament Trees. In the winner tree the winner of each competition is inside the nodes, however it is more efficient to keep the loser of the competitions in side the nodes and bubble the winner up the tree.posted on 2013-09-10 23:14lexus 阅读( ...) 评论( ...) 编辑 收藏 转载于:https://www.cnblogs.com/lexus/p/3313638.html
The loser tree has applications in areas such as Run Generations during external sorts, Bin-Packing Problems (Truck Loading), and others.
I am not yet sure of how to transfer my c++ knowledge of pointer to Python, so I used an array representation of the binary tree to keep track of the nodes. If anybody knows how I could implement a tree with pointers, I would love to know.
In anycase, below is my code. It isnt great code, and any suggestions would be great! Thanks to Yet Another Coding Blog for the code highlighting tip.
推荐阅读
- 数据分析|pandas学习(三) grouping
- 接口自动化测试|接口自动化(二)(接口联调)
- 分享3 个Python冷知识
- 10个你必须知道的Python内置函数
- pytorch|PyTorch 框架学习 更新中...
- 机器学习之python学习|时间序列框架-Darts-用户指南(中)
- 深度学习|Pytorch实践
- java|再见Java8!Java17 终于免费了,史上最快的 JDK。
- 人工智能|再见了Java8,Java17(我要取代你)