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
I just started with algorithms and I often see “<-” this and key[x] terminology can someone tell me what is key is it an array ? x was getting the root value and then it is used as an index ? I fail to understand this. Please explain.
It’s pseudocode (not a real language).
In this case
<-means ‘is assigned’ and can be thought of as doing what=does in modern languages.key[x]is shorthand for thekeyproperty of structure/objectx(this doesn’t mean it’s a member of thexclass necessarily, it could be retrieved from a data structure such as a map. The actual implementation is left up to the algorithm implementer.So the above algorithm could be written in C as: