标签: tree binary-tree binary-search-tree
给出二元搜索树的以下定义:
size(t)={ 0 , t= null 1+size(t.left)+size(t.right), otherwise
对于树中的每个顶点,t.size包含其子树的大小
编写一个算法,该算法将命名为selection(T,i),给定的根到树T,每个顶点都有大小值,这将返回树中大小为i的值。
算法应该具有最小的复杂时间。
有人知道如何解决它吗?