有一个树可以对一个对象排名? [英] Is there a tree that can rank an object?

查看:91
本文介绍了有一个树可以对一个对象排名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个红黑二进制统计树,以获得与红黑树中其他对象相当的任意对象的排名,我不知道是否有一个API类提供相同的功能。 p>

如果给定一个等级,该类也会很好,该类有一个函数来返回树中该等级的对象。



请注意,Red-black BST允许在log(n)时间内执行这两个操作,其中n是树中的对象数。

解决方案

标准API没有订单统计树。 TreeMap 特别没有找到密钥排名的方法,



它看起来不像通常的附加库(Apache Commons Collections,Google Guava)有一个顺序统计树。


I"ve coded a Red Black binary statistic tree to get the rank of an arbitrary object that is comparable to the other objects in the Red Black tree. I wonder if there is an API class that provides the same functionality.

It would also be nice if given a rank, the class has a function to return an object of that rank within the tree.

Note that the Red-black BST allows these two operations in log(n) time where n is the number of objects in the tree.

解决方案

The standard API doesn't have an order statistic tree. TreeMap in particular doesn't have methods for finding the rank of a key, or finding a key by rank in O(log n) time.

It doesn't look like usual add-on libraries (Apache Commons Collections, Google Guava) have an order statistic tree, either.

这篇关于有一个树可以对一个对象排名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆