문제

if right[x] != NIL
 then return TREE-MINIMUM(right[x])

 y<-p[x]
 while y!= NIL and x = right[y]
  do x<-y
  y<-p[y]
 return y

I know what "if right[x] != NIL then return tree-min" means and I've translated it to:

if(p->RChild) return fMinValue(p->RChild);//returns the min value of the sub-tree starting at the right child node of p

The rest I'm having trouble understanding.

도움이 되었습니까?

해결책

<- is most likely the assignment operator. p I would guess is parent. What else are you confused about?

다른 팁

Here p[] almost certainly means "the parent node of". You're working on node x, so p[x] means "the parent of the current node" (just like right[x] means "the right-hand child of the current node").

The <- notation is assignment. Like = in c-like languages.

The second part of the algorithm presented here walks up the tree looking for the first time you ascended a left link instead of a right one. But I'm not sure that I would describe this as a successor function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top