Decision Tree & Table

Decision tree

n When a decision table is not too complex, it may be presented graphically as a decision tree to help our understanding of the logic.

n Like decision tables, decision trees show how conditions are related to actions.

n However, the tree format shows how conditions are combined to lead to a particular action.  This is the only advantage trees have over the more compact tables

n Usually drawn from un-optimised, limited entry decision tables.

n Often used in preference to decision tables where there are not too many decision points and each action applies to only one case.

n A decision tree is written (and read) from left to right.

n It will have a list of actions recorded at the extreme right.

n Work by recursively partitioning the data based on input field values

n Data partitions are called branches

n Initial branch (root) split into subsets (child branches) based on value of input field

n Subsets can be further divided until process is complete – terminal branches or leaves

Decision Table

n Decision tables are used as a method of defining the logic of a process in a compact manner.

n Convenient to use in a program where a large number of logical alternatives exist (i.e. assume that a process being specified equates roughly to a program in the system).  The basic format of the decision table consists of four quadrants:

Condition

Stub:  specifies values of the data we wish to test for

Condition Entry:  specifies what the above values may be

Action Stub – specifies the actions that may be taken

Action Entry – shows the action or actions that will be performed

for each rule (in the condition entry).  The columns are marked

with an ‘X’ opposite the action(s) to be taken

 Is it raining? Y Y Y Y N N N N Is it December? Y Y N N Y Y N N Is it windy? Y N Y N Y N Y N

Y = Yes

N = No

Scenario

A person should never go to work if it is raining in December.

If he does go to work, he should take an umbrella when it is raining and an overcoat when it is windy. Unless it is windy he

must always take his hat when going to work. If it is windy in December he should switch on his central heating.  From this description we can isolate six actions:

n Stay at home

n Go to work

n Take umbrella

n Take overcoat

n Take hat

n Switch on central heating

Example – Decision Table

 Condition 1 2 3 4 5 6 7 8 Is it raining? Y Y Y Y N N N N Is it December? Y Y N N Y Y N N Is it windy? Y N Y N Y N Y N Action Stay at home X X X X X X X X Go to work X X X X X X X Take umbrella X X X Take overcoat Take Hat Switch on Heating

Feedback Form

[contact-form-7 id="98" title="Feedback Form"]