Skip to content

Instantly share code, notes, and snippets.

@obstschale
Created June 22, 2012 08:56
Show Gist options
  • Save obstschale/2971468 to your computer and use it in GitHub Desktop.
Save obstschale/2971468 to your computer and use it in GitHub Desktop.
Print a binary tree
void padding ( char ch, int n ){
int i;
for ( i = 0; i < n; i++ )
putchar ( ch );
}
void structure ( struct node *root, int level ){
int i;
if ( root == NULL ) {
padding ( '\t', level );
puts ( "~" );
} else {
structure ( root->right, level + 1 );
padding ( '\t', level );
printf ( "%d\n", root->info );
structure ( root->left, level + 1 );
}
}
int main ( void ){
struct node *tree = NULL;
/* ... */
structure ( tree, 0 );
/* ... */
}
@shivanshu-semwal
Copy link

void structure ( struct node *root, int level ){ int i;
what does int i; stand for?

It's useless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment