A Ternary Tree (T) is a tree in which every non terminal node has at most 3 children.

We will use T to simulate the following activity:

A set of P candidates must pass a set of exams ordered in an array of N exam codes (an exam code is an array of char). For a given exam, a candidate can be in one of the 3 following cases: success, failure or non-passed exam yet. Thus, every T node represents an exam with: exam code as root, succeeded candidates as left child, failed candidates as right child and in the middle whose didnâ€™t pass exam yet. The following figure depicts 2 exams and the situation of 10 candidates: how to write it :)

0