python|Loser tree in Python | Christan Christens

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.

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.
posted on 2013-09-10 23:14lexus 阅读( ...) 评论( ...) 编辑 收藏 转载于:https://www.cnblogs.com/lexus/p/3313638.html

    推荐阅读