0

i get a stack error

template <class KT, class DT>
void my_bst<KT,DT>::show_bst_structure() const
{
	my_bst_node<KT,DT>* b=root;
	show_bst_structure(b,0);
}

template <class KT, class DT>
void my_bst<KT,DT>::show_bst_structure(my_bst_node<KT,DT>*& p, int level) const
{
	int i;
	if ( root == NULL ) 
	{
		for ( i = 0; i < level; i++ )
		{
			putchar ( '\t' );
			puts ( "~" );
		}
	}
	else
	{
		if(p->left!=NULL)
		{
			show_bst_structure(root->left, level + 1 );
			for ( i = 0; i < level; i++ )
			{
				putchar ( '\t' );
				printf ( "%d\n", root->data );
			}
		}
		else if(p->right!=NULL)
		{
			show_bst_structure( root->right, level + 1 );
			for ( i = 0; i < level; i++ )
			{
				putchar ( '\t' );
				printf ( "%d\n", root->data );
			}
		}
   }

}

Edited by lotrsimp12345: n/a

1
Contributor
1
Reply
3
Views
8 Years
Discussion Span
Last Post by lotrsimp12345
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.