Information

Author(s) Anthony Doeraene
Deadline No deadline
Submission limit No limitation

Tags

Sign in

Inorder Traversal

In this exercice, you have to write a function which will travel a tree tree_t according to an inorder tour. As a reminder, an inorder tour visits the nodes in this order:

  1. The left sub-tree
  2. The actual node
  3. The right sub-tree

The structure tree_t is defined as below:

typedef struct tree{
    int value;              // the value at root of this tree
    int number_elements;    // number of elements in the tree
                            // bellow this root (including self)
    struct tree *left;      // left sub-tree
    struct tree *right;     // right sub-tree
}tree_t;


/**
*              1
*             / \
*            0   2
*           /
*         -1
*
* => tree(1).number_elements = 4 because it has 3 childs + himself
*/

Question 1: Inorder traversal
/**
* @brief Travel in a in-order tour the binary tree
*
* @pre tree : the binary tree to travel
* @post int* : an array containing the list of integers according
*                 to the in-order tour;
*              NULL if the tree is NULL, or if an error occurs
*/
int *in_order(tree_t *tree){
Question 2: Méthodes auxiliaires

Ecrivez ici vos méthodes auxiliaires