This commit is contained in:
Macko 2024-04-18 15:25:22 +02:00
parent 01919821be
commit 3449fce81e

View File

@ -1,27 +1,10 @@
#include "binary_search_tree.h"
#include <stdlib.h>
#ifndef BINARY_SEARCH_TREE_H
#define BINARY_SEARCH_TREE_H
#include <stddef.h>
typedef struct node node_t;
struct node {
node_t *right;
node_t *left;
int data;
};
node_t *build_tree(int *tree_data, size_t tree_data_len);
void free_tree(node_t *tree);
int *sorted_data(node_t *tree);
#endif
// Deklarace proměnné sorted_index
static int sorted_index;
// Deklarace funkce insert
// Definice funkce insert
node_t* insert(node_t *node, int data) {
if (node == NULL) {
node_t *new_node = (node_t*)malloc(sizeof(node_t));
@ -37,7 +20,7 @@ node_t* insert(node_t *node, int data) {
}
}
// Deklarace funkce inorder_traversal
// Definice funkce inorder_traversal
void inorder_traversal(node_t *node, int *sorted) {
if (node == NULL) return;
inorder_traversal(node->left, sorted);