blob: bce0f77f19db457003f1fc465a51c30e1f656fcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <stddef.h>
#include <stdio.h>
#include "binary_tree.h"
void dfs_print_prefix(const struct binary_tree *tree)
{
if (tree == NULL)
{
return;
}
printf("%d ", tree->data);
dfs_print_prefix(tree->left);
dfs_print_prefix(tree->right);
}
void dfs_print_infix(const struct binary_tree *tree)
{
if (tree == NULL)
{
return;
}
dfs_print_infix(tree->left);
printf("%d ", tree->data);
dfs_print_infix(tree->right);
}
void dfs_print_postfix(const struct binary_tree *tree)
{
if (tree == NULL)
{
return;
}
dfs_print_postfix(tree->left);
dfs_print_postfix(tree->right);
printf("%d ", tree->data);
}
|