tags:

views:

303

answers:

3
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.

+1  A: 

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

David Kanarek
p[x] and p[y]. Is p a pointer and the contents of [] is what p is pointing to?Edit: =) It makes sense now. Thank you!
Azreal
The way I'm reading it, `p[x]` is a function which returns the parent of node `x`. `right[x]` would be the right child of `x` then.
David Kanarek
+2  A: 

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.

dmckee
A: 

i'm sorry to ask but what does "!" mean in pseudo-code? i know "!" stands for factorial but i can't translate it .

ex:

get operation if (operation!= ’B’ OR operation != ’D’ OR operation!= ’W’) then print "Invalid Operation"

whaT does it mean? please help my mid-term is in hours :S

Thnx in advance for your help :)

Dina
!= is the same as saying, "not equal to"
Azreal
-1: not an answer - this should be a comment
Paul R