He guys,
I am trying to figure out what is wrong with this code for level traversal in binary tree in C. I would really appreciate any help or suggestion or changes in my code.
status level_traverse( tree T, status( *p_func_f ) () ) {
tree *node ;
queue q ;
if( init_queue( &q ) == ERROR ) return ERROR ;
if( qadd( &q, T ) == ERROR ) return ERROR ;
while( ! empty_queue( &q ) ) {
if( node != NULL ) {
qremove ( &q, ( generic_ptr * ) &node ) ;
qadd( &q, ( generic_ptr ) LEFT( T ) ) ;
qadd( &q, ( generic_ptr ) RIGHT( T ) ) ;
}
}
return OK ;
}
I already have it printing out in my main.c and we are supposed to use it so it returns status. If you guys know any other way to do it, please let me know. I will try that too..
Thanks