Tags

No tags :(

A question came up on Quora site.

Can you create a decision tree diagram to find all 3 digits numbers whose sum of its digits is 5.
for example 203 would be such a number.

A decision tree can be constructed to find all of the numbers but instead let’s use a smaller tree and some counting methods.
First we will create a tree for sum of 3 digits is 5 but will require the tree to be in ascending order (next digit greater than or equal to previous one).
With these requirements we have two small trees that :

__0__
0  1   2
5  4   3

This tree gives us numbers 005, 014, and 023 (each has sum of digits = 5)

_1_
1   2
3   2

This tree gives us numbers 113 and 122

To get the remaining number count we can use some counting techniques.

Let’s look at 014 – how many 3 digit numbers are made using these 3 digits? The answer is 5.

0 can be in position 1,2 or 3 -> 0_ _; _ 0 _; _ _ 0

For each one of these positions the 1,4 digits can be in 2 spots -> thus we have a total of 3*2 = 6 unique 3 digit numbers using 014 -> 014; 041; 104; 401; 140; 410

We can use the same logic for 023 for another 6 unique 3 digit numbers

The remaining number 005; 113 and 122 are different, but easier, since two of the digits are the same.

For each one the unique digit can be in one of 3 positions so each will have 3 unique 3 digit numbers.
For example: 005 050 500.

In summary:

014; 023 give 12 unique 3 digit numbers

005; 113; 122 give 9 unique 3 digit numbers

For a total of 21 unique 3 digit numbers whose sum is 5.