From 5ff9a40338911391c5795149141c2e90d04487f4 Mon Sep 17 00:00:00 2001 From: savolla Date: Sun, 23 Aug 2020 00:28:20 +0300 Subject: [PATCH] Added postOrder and preOrder functions --- .../binary_trees/binary_search_tree.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/data_structures/binary_trees/binary_search_tree.c b/data_structures/binary_trees/binary_search_tree.c index 9af1d5fa01..faaedb7880 100644 --- a/data_structures/binary_trees/binary_search_tree.c +++ b/data_structures/binary_trees/binary_search_tree.c @@ -245,6 +245,32 @@ void inOrder(node *root) } } +/** Traversal procedure that can be used for copying the tree + * @param root pointer to parent node + */ +void preOrder(node *root) +{ + if (root != NULL) + { + printf("\t[ %d ]\t", root->data); + preOrder(root->left); + preOrder(root->right); + } +} + +/** Traversal procedure that can be used for delete the tree + * @param root pointer to parent node + */ +void postOrder(node *root) +{ + if (root != NULL) + { + postOrder(root->left); + postOrder(root->right); + printf("\t[ %d ]\t", root->data); + } +} + /** Main funcion */ int main() {