Major Topics Major Topics Structured English Flowcharts Decision Tables Decision Trees Decision Criteria
Nov 17, 2014
Major TopicsMajor Topics
Structured English Flowcharts Decision Tables Decision Trees Decision Criteria
Structured EnglishStructured English Structured English is a
technique used to describe algorithmic procedures and is sometimes considered an alternative to flowcharts.
ExampleExample
IF Hours is greater than 40
THEN Compute Overtime
PayELSE Compute Regular PayENDIF
Y NHours > 40
ComputeOvertime
ComputeRegular
What are Flowcharts?What are Flowcharts?
They describe a procedure or program by specifying the sequence diagrammatically in which individual steps must be executed.
An ideal means for documenting complex algorithms so that users can refer to them as procedural guides.
Flowchart SymbolsFlowchart Symbols
Terminal(Start/Stop)
Process
Flow Line
Input/Output
Decisionor Test
Connector
Simple ExampleSimple Example
Start
Print Headings
Read aNumber
A
A
EOF?
Stop
N
PrintNumber,Square
Procedure reads numbers from afile and produces a Table of the
numbers and their squares.
Procedure reads numbers from afile and produces a Table of the
numbers and their squares.
Decision TablesDecision Tables
A Decision table is a table of rows and columns, separated into four quadrants and is designed to illustrate complex decision rules Condition Stub – upper left quadrant Rules Stub – upper right quadrant Action Stub – bottom left quadrant Entries Stub - bottom right quadrant
Decision Table LayoutDecision Table Layout Standard format used for
presenting decision tables.
DecisionStub
RulesStub
ActionStub
EntriesStub
Decision Table ExampleDecision Table Example
1 2 3 4Like Boss? Y Y N N
20% Pay Raise? Y N Y NStay Another Year X XQuit after 2 Months X
Quit next Week X
Developing Decision Developing Decision TablesTables
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
Number of RulesNumber of Rules
Each condition generally has two possible alternatives (outcomes): Yes or No
In more advanced tables, multiple outcomes for each condition are permitted
The total number of rules is equal to 2 no. of conditions
Thus, if there are four conditions, there
will be sixteen possible rules
Building the TableBuilding the Table For each rule, select the appropriate
action and indicate with an ‘X’ Identify rules that produce the same
actions and attempt to combine those rules; for example:
Condition 1 Y Y Condition 1 YCondition 2 Y N Condition 2 - Action 1 X X Action 1 X
Cleaning Things UpCleaning Things Up Check the table for any impossible
situations, contradictions, and redundancies and eliminate such rules
Rewrite the decision table with the most reduced set of rules; rearranging the rule order is permissible if it improves user understanding
Decision Table example: Decision Table example: combine and reducecombine and reduce
Conditions and Actions 1 2 3 4 5 6 7 8
Order from Fall Catalog Y Y Y Y N N N NOrder from Christmas Catalog Y Y N N Y Y N NOrder from Special Catalog Y N Y N Y N Y NMail Christmas Catalog X X X XMail Special Catalog X XMail Both Catalogs X X
The four gray columns canbe combined into a single rule. Note that four each,there was NO order placedfrom the Special Catalog.
In addition, Rules 1&5 andRules 3&7 can be combined.Each pair produces the same
action and each pair shares twocommon conditions.
Decision Table example Decision Table example ~ Final Version~ Final Version
Conditions and Actions 1 2 3
Order from Fall Catalog -- -- --Order from Christmas Catalog Y -- NOrder from Special Catalog Y N YMail Christmas Catalog XMail Special Catalog XMail Both Catalogs X
Eliminates the need to check for every possible case.
Decision Table Decision Table example:example:
checking for completeness and checking for completeness and accuracyaccuracy
Conditions and Actions 1 2 3 4
Salary > $50,000 per year Y Y N NSalary < $2,000 per month Y N Y NAward Double Bonus XAward Regular Bonus XAward no Bonus X
Although the Y-N Combinations suggest a rule, in this case, it is impossible for conditions 1 & 2 to
existsimultaneously. They are in complete
contradiction with each other. In the final version of the table,
Rule 1 will disappear and Rules -4 will become Rules 1-3.
Importance of Decision Importance of Decision TablesTables
Aids in the analysis of structured decisions
Ensures completeness Checks for possible errors (impossible
situations, contradictions, and redundancies, etc.)
Reduces the amount of condition testing that must be done
Decision Trees Decision Trees
Decision trees are useful when multiple branching occurs in a structured decision process, although they can be quite effective when only two decision paths are called for.
They are helpful when necessary to maintain a certain order for a series of decisions.
DrawingDrawing Decision Trees Decision Trees
Drawn horizontally
Root of tree is to the left side
Square Nodes indicate actions
Circle Nodes represent possible conditions
Circle is analogous to the condition part of an IF statement
Square is analogous to the consequent of an IF statement (the ‘THEN’ part)
“IF Circle THEN Square”
Decision Trees Decision Trees
Assume the following discount policy: “ Bookstores get a trade discount of
25%; for orders from libraries and individuals, 5% allowed on orders of 6-19 copies per book title; 10% on orders for 20-49 copies per book title;15% on orders for 50 copies or more per book title.”
Using the Decision Table describe the above mentioned discount policy.
Decision Tree ExampleDecision Tree Example
1
booksto
re 2
3
libraries & individuals
4Osize>=50 25% Discount
5
Osize<50 Nil Discount
Osize
:6-1
9 6 5% Discount
Osize:20-49 710% Discount
Osize>50
8 15 % Discount