A clarification about "Tree Building" exercise and non-continuos IDs

Hi, I am puzzled about the meaning of the test case “non-continuous”. From intuitive reasoning, I don’t see a problem that a record ID is missing provided that each grandchild always has a parent. In particular for the test case “non-continuous” the output

0:[1: 2:[4:]]

seems entirely acceptable to me. I have the following suggestions:

  1. remove the test case
  2. add the constraint in the description of the exercise

What do you think?

Thank you

Welcome to the forum!

That output has 4 records, and it has a record with id==4. According to the instructions, that would not be possible:

The ID number is always between 0 (inclusive) and the length of the record list (exclusive).

If the length of the record list is 4 in that example, this constraint is effectively saying we can only have ids up to 3 (inclusive). Indirectly, this constraint is also saying that the ids have to be continuous, because that’s the only way you can have n records with different ids while ensuring their ids are in the range [0, n-1].

I think the tests and instructions are technically correct, but maybe we can improve the wording in the instructions. Feel free to give any suggestions on how to word this differently in a way that you think is more clear.

1 Like

Thank you very much, you are completely right. The formulation is stating that and after re-reading it is completely clear. This solves completely the problem and at this moment I don’t think that it requires a reformulation.

Kind regards,
Silvio