forked from josanri/Libft_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_btree_level_count.c
34 lines (31 loc) · 1.27 KB
/
ft_btree_level_count.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_btree_level_count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: josesanc <josesanc@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/18 19:41:55 by josesanc #+# #+# */
/* Updated: 2023/02/18 19:41:55 by josesanc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Counts the largest branch of the tree
*
* @param root
* @return int
*/
int ft_btree_level_count(t_btree *root)
{
int left_size;
int right_size;
if (root == NULL)
return (0);
left_size = ft_btree_level_count(root->left);
right_size = ft_btree_level_count(root->right);
if (left_size > right_size)
return (left_size + 1);
else
return (right_size + 1);
}