Compare commits
4 Commits
master
...
branchjona
| Author | SHA1 | Date | |
|---|---|---|---|
| d1320cf6b7 | |||
| 369c019c30 | |||
| cccc013b99 | |||
| 9a79ff0ad4 |
14
bintree.c
14
bintree.c
@ -12,7 +12,6 @@
|
|||||||
* `nextTreeData`: Traversierung mit Hilfe des zuvor implementierten Stacks. Done */
|
* `nextTreeData`: Traversierung mit Hilfe des zuvor implementierten Stacks. Done */
|
||||||
|
|
||||||
|
|
||||||
static TreeNode *root = NULL;
|
|
||||||
static StackNode *stackRoot = NULL;
|
static StackNode *stackRoot = NULL;
|
||||||
|
|
||||||
|
|
||||||
@ -56,10 +55,16 @@ TreeNode *addToTreeRec(TreeNode *currentNode, TreeNode *newNode, CompareFctType
|
|||||||
{
|
{
|
||||||
if ((isDuplicate == NULL) || root)
|
if ((isDuplicate == NULL) || root)
|
||||||
{
|
{
|
||||||
|
if (isDuplicate != NULL)
|
||||||
|
{
|
||||||
|
*isDuplicate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
*isDuplicate = 0;
|
||||||
return currentNode;
|
return currentNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +88,10 @@ TreeNode *addToTreeRec(TreeNode *currentNode, TreeNode *newNode, CompareFctType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDuplicate != NULL)
|
||||||
|
{
|
||||||
|
*isDuplicate = 0;
|
||||||
|
}
|
||||||
return currentNode;
|
return currentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,5 +193,7 @@ int treeSizeRec(const TreeNode *currentNode)
|
|||||||
nodeCount += treeSizeRec(currentNode->right);
|
nodeCount += treeSizeRec(currentNode->right);
|
||||||
return nodeCount + 1;
|
return nodeCount + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nodeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
runstackTests.exe
Normal file
BIN
runstackTests.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user