Skip to content

Commit 2705e92

Browse files
committed
BST code updated a little bit
1 parent 8798bbf commit 2705e92

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Data Structure/BST/binary_serarch_tree.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,30 @@ void inOrderPrint(node *rootNode) // InOrder Traversal (left-root-right)
6868
inOrderPrint(rootNode->rightChild);
6969
}
7070

71+
void preOrderPrint(node *rootNode) // PreOrder Traversal (root-left-right)
72+
{
73+
if(rootNode==NULL)
74+
return;
75+
76+
printf("%d ", rootNode->number);
77+
78+
preOrderPrint(rootNode->leftChild);
79+
80+
preOrderPrint(rootNode->rightChild);
81+
}
82+
83+
void postOrderPrint(node *rootNode) // PostOrder Traversal (left-right-root)
84+
{
85+
if(rootNode==NULL)
86+
return;
87+
88+
postOrderPrint(rootNode->leftChild);
89+
90+
postOrderPrint(rootNode->rightChild);
91+
92+
printf("%d ", rootNode->number);
93+
}
94+
7195
node* searchOnTree(int value)
7296
{
7397
node* currentNode = root;

0 commit comments

Comments
 (0)