Skip to content

Commit

Permalink
fixed mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiipatov committed Dec 18, 2021
1 parent 641fcc3 commit bbe5b69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions AVLtree/AVLtree/AVLtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ Node* fullBalance(Node* x, const char* key)
x->leftSon = fullBalance(x->leftSon, key);
}
correctHeight(x);
x = balance(x);
return x;
return balance(x);
}

void deleteNode(Dict** dict, const char* key)
Expand Down
20 changes: 11 additions & 9 deletions AVLtree/AVLtree/AVLtreeTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ bool insertItems(Dict* dict)
&& insert(dict, "-1", "fkpodsmgf");
}

bool testAddAndGet(Dict* dict)
bool testAddAndGet(void)
{
Dict* dict = createDictionary();
insert(dict, "6", "enrg");
if (dict == NULL)
{
Expand Down Expand Up @@ -127,11 +128,14 @@ bool testAddAndGet(Dict* dict)
deleteDictionary(&dict);
return false;
}
deleteDictionary(&dict);
return true;
}

bool testDeleteAndInDictionary(Dict* dict)
bool testDeleteAndInDictionary(void)
{
Dict* dict = createDictionary();
insertItems(dict);
deleteNode(&dict, "0");
if (inDictionary(dict, "0"))
{
Expand All @@ -149,14 +153,13 @@ bool testDeleteAndInDictionary(Dict* dict)
deleteNode(&dict, "3");
if (inDictionary(dict, "2") || inDictionary(dict, "19")
|| inDictionary(dict, "9") || inDictionary(dict, "3")
|| !inDictionary(dict, "8") || !inDictionary(dict, "6"))
|| !inDictionary(dict, "8"))
{
deleteDictionary(&dict);
return false;
}
deleteNode(&dict, "8");
deleteNode(&dict, "6");
if (inDictionary(dict, "8") || inDictionary(dict, "6"))
if (inDictionary(dict, "8"))
{
deleteDictionary(&dict);
return false;
Expand All @@ -165,9 +168,9 @@ bool testDeleteAndInDictionary(Dict* dict)
return dict == NULL;
}

bool testDeleteDictionary(Dict* dict)
bool testDeleteDictionary(void)
{
dict = createDictionary();
Dict* dict = createDictionary();
if (dict == NULL)
{
return false;
Expand All @@ -183,6 +186,5 @@ bool testDeleteDictionary(Dict* dict)

bool AvlTreePassedTests()
{
Dict* dict = createDictionary();
return testAddAndGet(dict) && testDeleteAndInDictionary(dict) && testDeleteDictionary(dict);
return testAddAndGet() && testDeleteAndInDictionary() && testDeleteDictionary();
}

0 comments on commit bbe5b69

Please sign in to comment.