Performance BST算法中计算给定范围内节点的运行时间
我得到了以下算法的伪代码,r是BST的根,x,y是x的数字Performance BST算法中计算给定范围内节点的运行时间,performance,time,Performance,Time,我得到了以下算法的伪代码,r是BST的根,x,y是x的数字 TreeCount(r,x,y) if r=null: return 0 if r<x: return TreeCount(r.right,x,y) if r>y: return TreeCount(r.left,x,y) return 1+TreeCount(r.right,x,y)+TreeCount(r.left,x,y)
TreeCount(r,x,y)
if r=null:
return 0
if r<x:
return TreeCount(r.right,x,y)
if r>y:
return TreeCount(r.left,x,y)
return 1+TreeCount(r.right,x,y)+TreeCount(r.left,x,y)