How would you print the biggest N numbers from big to small in a binary tree without put it in an array?
How would you print the biggest N numbers from big to small in a binary tree without put it in an array?
if you created your tree in-order, left to right, then traverse it in-order, right to left...
I know how to print All values but i don't know how to print N values.
Come on! How difficult is to change this (assuming you are traversing a binary three recursively):
To count how many "visits" you did?Code:void traverse(node_T *rootp) { if ( rootp ) { traverse( rootp->right ); visit( rootp ); traverse( rootp->left ); } }