Skip to main content

You need a pointer to pointer begin_list because the head may change. 3. ft_itoa_base (Classic tricky one) char *ft_itoa_base(int value, int base)

if (!node) return; // do something with node traverse(node->left); traverse(node->right);

// Handle special cases: INT_MIN, base 10, base 16, etc. // Recursive approach: // - Convert absolute value // - Build string from least significant digit // - Handle negative for base 10

typedef struct s_queue

> 1 (to start ex00)

> 2 ex01: ft_btree_insert_data // Write recursive insert... // Submit Moulinette: KO (segfault) // Debug: forgot to malloc node // Resubmit Moulinette: OK (4/4)

Forgetting that base can be 2, 8, 10, 16, but not 1 or >16 per subject. Also, value can be negative only for base 10. 4. ft_btree_insert_data (Hard) void ft_btree_insert_data(t_btree **root, void *item, int (*cmpf)())

t_list *current = *begin_list; t_list *previous = NULL; while (current)

// add to end

Good luck, and may your pointers never be dangling!

if (!node) return (ft_btree_create_node(item)); if (cmp(item, node->item) < 0) node->left = insert(node->left, item, cmp); else node->right = insert(node->right, item, cmp); return (node);

Review Your Cart Close Close
Your cart is empty

Recently viewed

Recently Viewed Recently Viewed
Social Media Social Media
Top Top