diff --git a/bintree.c b/bintree.c index 5cf82a9..2927e04 100644 --- a/bintree.c +++ b/bintree.c @@ -12,7 +12,26 @@ // if isDuplicate is NULL, otherwise ignores duplicates and sets isDuplicate to 1 (or to 0 if a new entry is added). TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFctType compareFct, int *isDuplicate) { + TreeNode newNode = {data, NULL, NULL}; + + if(root == NULL) + { + return &newNode; + } + + if (data < root->data) + { + root->left = addToTree(root->left, data, dataSize,compareFct, isDuplicate); + } + else if(data > root->data) + { + root->right = addToTree(root->right, data, dataSize,compareFct, isDuplicate); + } + + + + return root; } // Iterates over the tree given by root. Follows the usage of strtok. If tree is NULL, the next entry of the last tree given is returned in ordering direction. @@ -32,5 +51,12 @@ void clearTree(TreeNode *root) // Returns the number of entries in the tree given by root. unsigned int treeSize(const TreeNode *root) { + int counter = 0; + if(root != NULL) + { + treeSize(root->left); + counter++; + treeSize(root->right); + } } \ No newline at end of file diff --git a/numbers.o b/numbers.o deleted file mode 100644 index 507642a..0000000 Binary files a/numbers.o and /dev/null differ diff --git a/runNumbersTest.exe b/runNumbersTest.exe deleted file mode 100644 index e9feb27..0000000 Binary files a/runNumbersTest.exe and /dev/null differ