Re: The minimum value of a binary tree question
- From: "BGB / cr88192" <cr88192@xxxxxxxxxxx>
- Date: Mon, 18 Jan 2010 13:58:28 -0700
"Paul N" <gw7rib@xxxxxxx> wrote in message
news:9ffda5b8-c5f6-4164-bb56-fdc6791fadfe@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
code:
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...
.
- References:
- The minimum value of a binary tree question
- From: Chad
- Re: The minimum value of a binary tree question
- From: Daniel Pitts
- Re: The minimum value of a binary tree question
- From: Chad
- Re: The minimum value of a binary tree question
- From: Paul N
- The minimum value of a binary tree question
- Prev by Date: Re: The minimum value of a binary tree question
- Next by Date: Re: The minimum value of a binary tree question
- Previous by thread: Re: The minimum value of a binary tree question
- Next by thread: Re: The minimum value of a binary tree question
- Index(es):
Relevant Pages
|