This commit is contained in:
Weber 2024-04-27 19:20:50 +00:00
parent ac9e6f05d9
commit 68e5a47eb3

View File

@ -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);