1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

int func_count_node( node* p_tree)
{
int sum = 0;
if( p_tree>p_left != NULL)
{
sum += func_count_node( p_tree>p_left );
}
else if( p_tree>p_right != NULL)
{
sum += func_count_node( p_tree>p_right );
}
++sum;
return sum;
}
node* func_balance_tree( node* p_tree, node* p_array[], int num)
{
if( p_tree>p_left != NULL)
{
func_balance_tree( p_tree>p_left, p_array, ++num );
}
if( p_tree>p_left != NULL)
{
func_balance_tree( p_tree>p_right, p_array, ++num );
}
p_array[num] = p_tree;
}
void sort (node* array[], int size)
{
for ( int i = 0; i < size; i++ )
{
int index = findSmallestRemainingElement( array, size, i );
swap( array, i, index );
}
}
int findSmallestRemainingElement (node* array[], int size, int index)
{
int index_of_smallest_value = index;
for (int i = index + 1; i < size; i++)
{
if ( array[ i ]>number < array[ index_of_smallest_value ]>number )
{
index_of_smallest_value = i;
}
}
return index_of_smallest_value;
}
void swap (node* array[], int first_index, int second_index)
{
node* temp = array[ first_index ];
array[ first_index ] = array[ second_index ];
array[ second_index ] = temp;
}
