Re: The minimum value of a binary tree question

"Paul N" <gw7rib@xxxxxxx> wrote in message
On 18 Jan, 18:17, Chad <cdal...@xxxxxxxxx> wrote:
Oh yeah. I forgot that current->data is outside the loop. And this
reminds me that a while back I had asked a similar question on
comp.lang.c. I'm suspecting that there is some underlying programming
concept that I haven't quite grasped yet.

Perhaps you mean the concept of "look before you leap"?

For instance, if you want to find the end of a linked list, then this

while (thing) { thing = thing -> next; }

will not work because you run off the end of the list before you stop.
And once thing is NULL, you can't do "thing = thing -> prior" to get
back into the list again.

for some uses, it may be useful to instead keep a 'prev' pointer:
prev = NULL;
while (thing) { prev = thing; thing = thing -> next; }

granted, this would likely be pointless in this case, but this is also
useful for some cases...