-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2_reverse_tree.c
36 lines (31 loc) · 1.24 KB
/
2_reverse_tree.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* reverse_tree.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qpeng <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/30 00:45:10 by qpeng #+# #+# */
/* Updated: 2018/10/04 02:10:20 by qpeng ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
struct s_node
{
int value;
struct s_node *right;
struct s_node *left;
};
void reverse_tree(struct s_node *root)
{
if (root != NULL)
{
struct s_node *tmp;
tmp = root->right;
root->right = root->left;
root->left = tmp;
reverse_tree(root->left);
reverse_tree(root->right);
}
return ;
}