Rank 03 - 42 Exam
5 / \ 3 8 / \ \ 1 4 9 Trace ft_btree_apply_infix (left-root-right). Write the output before running code. Give yourself 20 minutes per exercise. If you exceed, look at the solution, understand it, then redo from scratch. 4. Understand the typedefs typedef struct s_list
if (!node) return; // do something with node traverse(node->left); traverse(node->right);
void *search(t_btree *node, void *ref, int (*cmp)()) 42 Exam Rank 03
if (!root) return (0); return (1 + max(ft_btree_level_count(root->left), ft_btree_level_count(root->right)));
Do not use recursion here — unnecessary and slower. 2. ft_list_remove_if (Medium) void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)()) 5 / \ 3 8 / \ \
// 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
// add to end
> 2 ex02: ft_itoa_base // Write carefully, test INT_MIN // Submit Moulinette: OK (4/4)
Introduction: What is Exam Rank 03? Exam Rank 03 is the third of five progressively difficult exams in the 42 curriculum (following Rank 00 and Rank 01, preceding Rank 04 and Rank 05). Unlike a school exam where you memorize facts, the 42 exam is a practical coding test in a restricted environment. If you exceed, look at the solution, understand
// remove from front
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);
