AfanasevGad7

This is a task for our favourite professor
git clone git://git.stellar-nexus.ru/AfanasevGad7
Log | Files | Refs

commit 64e728bf00f464bc60b46062f8d579f7318ae020
parent 211a3863e6d76ace6b2a18bbad70ea50220c1051
Author: Plat <plat@stellar-nexus.ru>
Date:   Sat, 18 Oct 2025 21:46:01 +0000

Added the parsing functions

Diffstat:
Mparser.c | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+), 0 deletions(-)

diff --git a/parser.c b/parser.c @@ -30,3 +30,57 @@ add(int val, Node *root) add(val, root->right); } } + +Node* +parse_pre(unsigned int *index, Node *root) +{ + if (!root) + return NULL; + + if (*index == 0) + return root; + --(*index) + + Node *res = parse_pre(node->left, index); + if (res) + return res; + + return parse_pre(node->right, index); +} + +Node* +parse_post(unsigned int *index, Node *root) +{ + if (!root) + return NULL; + + Node *res = parse_post(node->left, index); + if (res) + return res; + *res = parse_post(node->right, index); + if (res) + return res; + + if (*index == 0) + return root; + --(*index) + + return NULL; +} + +Node* +parse_inf(unsigned int *index, Node *root) +{ + if (!root) + return NULL; + + Node *res = parse_inf(node->left, index); + if (res) + return res; + + if (*index == 0) + return root; + --(*index) + + return parse_inf(node->right, index); +}