diff --git a/bintree.c b/bintree.c index 079cad5..96b2b48 100644 --- a/bintree.c +++ b/bintree.c @@ -35,11 +35,11 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc if (cmp == 0){ - + /* if (isDuplicate == NULL){ root->right = addToTree(root->right, data, dataSize, compareFct, NULL); return root; - } + }*/ *isDuplicate = 1; return root; @@ -60,7 +60,13 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc // push the top node and push all its left nodes. void *nextTreeData(TreeNode *root) { + if (root != NULL){ + + + + + } } // Releases all memory resources (including data copies). @@ -89,4 +95,13 @@ unsigned int treeSize(const TreeNode *root) unsigned int size = kidsleft + kidsright + 1; return size; +} + + +int compareFct(const void *a, const void *b){ + + if(*a>*b)return -1; + if(*b>*a)return 1; + if(*a==*b)return 0; + } \ No newline at end of file diff --git a/numbers.c b/numbers.c index 3cef3cd..b807838 100644 --- a/numbers.c +++ b/numbers.c @@ -19,30 +19,34 @@ unsigned int *createNumbers(unsigned int len) srand(time(NULL)); unsigned int* numbers =malloc(sizeof(unsigned int) * len); unsigned int numberTemp; - bool check = false; + unsigned int* numbTempPtr = &numberTemp; + int generated = 0; + int isDuplicate = 0; + TreeNode* root = NULL; - for(int i = 0; i < len; i++){ - while(check == false){ - numberTemp = (rand() % 2*len)+1; + while(genreated