【发布时间】:2012-11-01 11:48:07
【问题描述】:
Search(T,k)
x<- root[T]
while x != NULL and k != key[x]
do
if k<key[x]
then x <- left[x]
else x <- right[x]
return x
我刚从算法开始,我经常看到“
【问题讨论】:
-
这里的符号有点不同。
x中的key[x]不是索引。它实际上意味着“节点x处的键值”。与left[x]类似,right[x], they mean "the left and right nodes ofx. -
如果你更熟悉面向对象的表示法,你可以把
key[x]读成x.key,left[x]读成x.left等等。 -
@hammar,你不是说面向对象表示法下的 C 风格表示法吗?
标签: algorithm binary-tree binary-search-tree