Binary Tree problem

P

pentiumPunk

Lets say i have a binary tree that looks like this:


root -> O

O <--- one of the nodes i
need nodeValue's for ---> O



In my binary tree...i have recusively traced down to a leaf node ( no left
or right pointers). i want the nodeValue of my current node....how do i get
it, if all i have access to is the root node. and root->left->nodeValue
doesnt work because the user defines whether it goes to the left or right
from the root? thanks! ~pentiumPunk~
 
K

Karl Heinz Buchegger

pentiumPunk said:
Lets say i have a binary tree that looks like this:

root -> O

O <--- one of the nodes i
need nodeValue's for ---> O

In my binary tree...i have recusively traced down to a leaf node ( no left
or right pointers). i want the nodeValue of my current node....how do i get
it, if all i have access to is the root node. and root->left->nodeValue
doesnt work because the user defines whether it goes to the left or right
from the root? thanks! ~pentiumPunk~

Show the code you already have.
It is much easier to make suggestions, when we see what you have, where
you have problems and at what skill level you are operating.

But usually one has a find() function which returns a pointer
to the node. The caller then can do a lot of things with that
pointer, eg. use it to look up the data value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,362
Latest member
ChandaWagn

Latest Threads

Top