Vous êtes sur la page 1sur 18

Decision Trees and Tables

Process Specification
 To record detailed information about data
processes, process specification techniques
are used.

 These techniques specify the precise nature of


decision and specify the exact sequence of
actions to be taken in a particular process.

12/29/10
Techniques

Three Process Specification techniques are:

 Structured English (SE)

 Decision Tables

 Decision Trees

12/29/10
Structured English
 Structured English (SE) is a form of English with a
limited number of constructs and a limited
vocabulary. Most programs are made up of just
three structures:
Sequence, Selection, and Iteration

 As process specifications are eventually converted


into programs, it means we only need these
constructs.

12/29/10
::::::::::::::::::::::
DO Calculate-Invoice-Total
::::::::::::::::::::::

Calculate-Invoice-Total
IF delivery is local
IF order-value > £50
then add £5 to invoice-total
ELSE
add £10 to invoice-total
ENDIF
ELSE
add £20 to invoice-total
ENDIF
12/29/10
Decision Tables
 Decision tables are used as a method of defining the
logic of a process in a compact manner.
 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 Condition entry

Action stub Action entry

12/29/10
Decision Tables
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

12/29/10
Decision Table Example

1 2 3 4
Like Boss? Y Y N N
20% Pay Raise? Y N Y N
Stay Another Year X X
Quit after 2 Months X
Quit next Week X

12/29/10
Developing Decision
Tables
• Process requires the determination of
the number of conditions (inputs) that
affect the decision.
• The set of possible actions (outputs)
must likewise be determined
• The number of rules is computed
• Each rule must specify one or more
actions

12/29/10
Scenario – Weather Conditions

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:

 Stay at home
 Go to work
 Take umbrella
 Take overcoat
 Take hat
 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 X X X X X X X X
Stay at home X X X X X X X
Go to work X X X
Take umbrella
Take overcoat
Take hat
Switch on heating
Decision Trees
 When a decision table is not too complex, it may
be presented graphically as a decision tree to
help our understanding of the logic.

 Like decision tables, decision trees show how


conditions are related to actions.

 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.
12/29/10
Decision Trees cont.
Decision trees:

 Usually drawn from un-optimised, limited entry decision


tables.

 Often used in preference to decision tables where there are


not too many decision points and each action applies
to only one case.

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

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

12/29/10
Decision Trees cont.
 Work by recursively partitioning the data based
on input field values

 Data partitions are called branches

 Initial branch (root) split into subsets (child


branches) based on value of input field

 Subsets can be further divided until process is


complete – terminal branches or leaves
Structure of Decision Tree

Condition 2
-Action
(positive)
Condition 1
(positive) Condition 2 -Action
Title (negative)

Condition 1 Condition 2 -Action


(negative) (positive)
Condition 2 -Action
(negative)
Example – Decision Tree
Limitations
 Can be formed from very complex process logic,
but this is difficult as their construction tends to
be less structured than that of decision tables.

 It is conventional to structure the decisions so that


each only has two outcomes. This can lead to
several problems, such as an inefficient program,
if it is designed according to the tree.

12/29/10

Vous aimerez peut-être aussi