数据结构与算法习题 loser tree(败方树)
Time Limit: 1000ms Memory Limit: 65536kB
Description
Given an interger array,you are required toconstruct a loser tree for it(compare twoadjacent array elements, and the comparison starts from the first element). Several modifications are made to the elements of the array. You arerequired to output the interger that every internal node represents for theloser trees that you constructed at first and got after every modification(theintergers are output according to the position of the internal node, from top tobottom,from left to right)
Input
The first line is the size of the array n and the number of modifications m.
The second line contains n intergers, they are elements of the array.
The next m lines represents the m modifications, every modification change the value of one element, each line contains two intergers, the first one is the index of the element modified,and the second is the value modified to.
Output
The output contains m+1 lines.
The first line is output of the interger that every internal node represents for the loser tree that you constructed at first(the intergers are output according to the position of the internal node, from top to bottom,from left to right)
The next m lines is ouput of the interger that every internal node represents for the loser tree constructed after the m modifications(the intergers are output according to the position of the internal node, from top to bottom,fr

该博客介绍了如何构建和使用败方树进行多路归并排序,特别是针对输入数组进行元素修改的情况。博主通过示例展示了败方树在处理数据变化时的优势,指出实际实现可能未完全优化,鼓励读者深入研究书本中的高效实现和计算内部节点编号的方法。
最低0.47元/天 解锁文章
1609

被折叠的 条评论
为什么被折叠?



