Archived

This topic is now archived and is closed to further replies.

nodes in a bst

This topic is 5618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok when i have a binary tree created, i check for a leaf by seeing if its left or right is null. however why doesnt the same theory work for checking if its a node? like why doesnt this work if node-> right !=NULL or node->left !=null

Share this post


Link to post
Share on other sites
ok, maybe i''m a bit rusty one this... each item in a BST is a node, and a node with no sub-trees is a leaf, right? so wait... i meant:
leaf: left == NULL AND right == NULL
node: left != NULL OR right != NULL
yah, so if both left & right are NULL, it is a leaf (no subtrees), otherwise it is a node (if either is not NULL)...
er... i need some sleep already...

Share this post


Link to post
Share on other sites