Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

reverse binary tree c

void reverse_tree(tree_node_t* root) {
	
    if (root != NULL) {
    	
        // Reverse left and right sub-tree
        reverse_tree(root->left_child);
        reverse_tree(root->right_child);
        
        // Reverse two child nodes
        tree_node_t *temp = root->right_child;
        root->right_child = root->left_child;
        root->left_child  = temp;
        
	}

}
 
PREVIOUS NEXT
Tagged: #reverse #binary #tree
ADD COMMENT
Topic
Name
2+3 =