Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


5 digit number

Posted on 2011-10-24
Medium Priority
Last Modified: 2012-05-12
Hi guys: Can any one please expain this question according to that answer ? Thanks.

A 5 digit number is formed according to the following rules:

The number contains only the digits 1,2,3,4 and these digits may be repeated or unused.

The first digit is 1.

If D1D2 are consecutive digits and D1 not equals to 4, then D1 < D2

If D1D2 are consecutive digits and D1 = 4, then D2 = 1.

(In other words, digits must be in increasing order, except that any 4 must followed by 1. For example, 12413 is one such number.) How many numbers of this type are there? Use a decision tree to compute your answer.

Question by:mustish1
  • 4
  • 2
  • 2
LVL 37

Accepted Solution

TommySzalapski earned 1000 total points
ID: 37020845
You are supposed to find all possible 5 digit numbers that fit those rules.
The first digit has to be a one. Then each next digit can be either 2, 3, or 4.
Each next digit just has to be greater than the previous (and be from 1 to 4) unless the previous is 4 in which case the next is always two.

The tree is showing all the possible numbers. So if you trace the tree from the root (top) to any leaf node (on the bottom) and write down all the numbers you pass on the way down, you will get a 5 digit number that satisfies those rules. If you do that for each leaf node, you will get all of them.
LVL 37

Expert Comment

ID: 37020855
If the problem did not include the tree, then you could easily build it yourself following the rules. Each node in the tree has nodes under it that represent digits allowed to follow that one.

Author Comment

ID: 37020904
Why these numbers are not in order like in the center the vertical line 1,3,4,1. Why its not 1,2,3,4
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 37021002
Also what does it means in the answer that there are 11 such numbers.

Author Comment

ID: 37021097
From the top node is 1 then it goes to 2, 3 and 4 on the left but why its not the same way on the right
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 1000 total points
ID: 37021153
After 1 at the top there are three possibilities. It can be either 2 (left), 3 (middle) or 4 (right).

After this 2 there can be either 3 or 4 as shown

After the middle 3 there can be only a 4 which is shown.

After the left 4 there can be only a 1 which is shown.

This sequence follows and you get the tree shown above.

This tree shows all the different combinations possible which can be counted at the bottom line of the diagram.

Author Comment

ID: 37021166
k thanks. Just one last question why in  diagram it says that there are 11 such numbers.
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37021172
Count the bottom ends

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding a job can be stressful - searches, resume tweaks, and networking events can be super boring. Luckily we're here to help you land your dream job!
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…
Where to go on the main page to find the job listings. How to apply to a job that you are interested in from the list that is featured on our Careers page.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question