From 8876568a45bb8dd8e5422c72bbc1982f4c466c49 Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 25 Apr 2024 21:23:56 +0200 Subject: [PATCH] Initializtion --- a3/binary_search_tree.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/a3/binary_search_tree.c b/a3/binary_search_tree.c index c9db5d4..43fc14a 100644 --- a/a3/binary_search_tree.c +++ b/a3/binary_search_tree.c @@ -29,31 +29,4 @@ node_t *build_tree(int *tree_data, size_t tree_data_len) { tree = insert_node(tree, tree_data[i]); } return tree; -} - -void free_tree(node_t *tree) { - if (tree == NULL) { - return; - } - - free_tree(tree->left); - free_tree(tree->right); - free(tree); -} - -void in_order_traversal(node_t *tree, int *sorted_data, int *index) { - if (tree == NULL) { - return; - } - - in_order_traversal(tree->left, sorted_data, index); - sorted_data[(*index)++] = tree->data; - in_order_traversal(tree->right, sorted_data, index); -} - -int *sorted_data(node_t *tree, size_t tree_data_len) { - int *sorted_data = (int *)malloc(tree_data_len * sizeof(int)); - int index = 0; - in_order_traversal(tree, sorted_data, &index); - return sorted_data; } \ No newline at end of file