Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to search a tree(postorder) in C

$
0
0
I write a function to search a tree, and find out the node suitable and store them in an array. It is in postorder.
void search_for_node(node *root, node *list[])
{
	int j;
	if (root == NULL)
		return;
	
	
	for(j=0; j<root->num_children; j++)
		search_for_node(root->children[j], list);
	if (root->type == ID)
	list[num_for++] = root;

	
	
}



But it can't work. Is there anything wrong in my code?
Thanks in advance!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>