test
This commit is contained in:
parent
ac9e6f05d9
commit
68e5a47eb3
@ -47,6 +47,12 @@ static void inorder_traversal(node_t *root, int *sorted_array, size_t *index) {
|
||||
}
|
||||
}
|
||||
|
||||
static size_t count_nodes_helper(node_t *root);
|
||||
|
||||
size_t count_nodes(node_t *tree) {
|
||||
return count_nodes_helper(tree);
|
||||
}
|
||||
|
||||
static size_t count_nodes_helper(node_t *root) {
|
||||
if (root == NULL) {
|
||||
return 0;
|
||||
@ -54,10 +60,6 @@ static size_t count_nodes_helper(node_t *root) {
|
||||
return 1 + count_nodes_helper(root->left) + count_nodes_helper(root->right);
|
||||
}
|
||||
|
||||
size_t count_nodes(node_t *tree) {
|
||||
return count_nodes_helper(tree);
|
||||
}
|
||||
|
||||
int *sorted_data(node_t *tree) {
|
||||
size_t index = 0;
|
||||
size_t num_nodes = count_nodes(tree);
|
||||
|
Loading…
Reference in New Issue
Block a user