aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/tree.c b/tree.c
index 8d4efe9..f8277cd 100644
--- a/tree.c
+++ b/tree.c
@@ -16,15 +16,7 @@ struct tree_node {
16 /* ggf. weitere Felder... */ 16 /* ggf. weitere Felder... */
17}; 17};
18 18
19static bool tree_isBstUntil(struct tree_node *tree, int min, int max); 19static bool
20
21bool
22tree_isBst(struct tree_node *tree)
23{
24 return tree_isBstUntil(tree, INT_MIN, INT_MAX);
25}
26
27bool
28tree_isBstUntil(struct tree_node *tree, int min, int max) 20tree_isBstUntil(struct tree_node *tree, int min, int max)
29{ 21{
30 if ( tree == NULL ) 22 if ( tree == NULL )
@@ -37,6 +29,12 @@ tree_isBstUntil(struct tree_node *tree, int min, int max)
37 tree_isBstUntil(tree->right, tree->key + 1, max); 29 tree_isBstUntil(tree->right, tree->key + 1, max);
38} 30}
39 31
32bool
33tree_isBst(struct tree_node *tree)
34{
35 return tree_isBstUntil(tree, INT_MIN, INT_MAX);
36}
37
40struct tree_node * 38struct tree_node *
41tree_insert(struct tree_node *tree, T key) 39tree_insert(struct tree_node *tree, T key)
42{ 40{