Decision Tree
Overview
A Decision Tree is a Logic Block that accepts one or more inputs and produces one or more outputs using a flowchart-based approach to decision-making. Decision Trees use a visual, hierarchical structure where each node represents a decision point that determines the path to the final outcome.
Decision Trees are ideal when:
- Decisions follow a clear sequence of questions
- The logic has a natural hierarchical structure
- Business users think in terms of "if this, then ask that"
- You want to visualize the decision path
Unlike Decision Tables where decisions are evaluated top-to-bottom in a flat structure, Decision Trees evaluate conditions along a path from root to leaf. Each decision node has branches leading to either another decision or a final outcome.
How Decision Trees Work
Evaluation starts at the root node and proceeds through the tree:
- At each decision node, evaluate the condition
- Follow the branch that matches the condition result
- Continue until reaching a leaf node (outcome)
- The leaf node's outputs are returned
This path-based evaluation means each input might only be evaluated once (at its decision node), unlike Decision Tables where every decision row checks all conditions.
Structure
A Decision Tree consists of:
| Component | Description |
|---|---|
| Name | Unique identifier for the Decision Tree |
| Description | What decision the tree makes |
| Inputs | Available data for decision nodes |
| Outputs | Values produced at leaf nodes |
| Root Node | Starting point of the tree |
| Decision Nodes | Points where conditions are evaluated |
| Leaf Nodes | Endpoints that produce outputs |
Decision Nodes
A decision node contains:
- Condition: What to evaluate
- Branches: Paths to follow based on condition result
Common condition patterns:
| Pattern | Example |
|---|---|
| Yes/No | IsVIP? → Yes branch, No branch |
| Comparison | Amount > 1000? → True branch, False branch |
| Categories | CustomerType? → Individual branch, Business branch, Government branch |
| Ranges | Score? → 0-50 branch, 51-75 branch, 76-100 branch |
Leaf Nodes
A leaf node is the end of a decision path. It specifies the outputs to return when that path is reached. Every possible path through the tree must end at a leaf node.
Example: Credit Approval Decision Tree
Name: CreditApprovalDecision
Inputs:
CreditScore(Integer): Applicant's credit scoreAnnualIncome(Money): Applicant's annual incomeExistingDebt(Money): Current debt obligationsEmploymentYears(Integer): Years at current employer
Outputs:
Decision(String): Approved, Declined, Manual ReviewCreditLimit(Money): Approved credit limitInterestRate(Decimal): Interest rate offeredReason(String): Explanation of decision
Tree Structure:
┌─────────────────┐
│ Credit Score? │
└────────┬────────┘
│
┌─────────────────┼─────────────────┐
│ │ │
[Less than 580] [580-699] [700 or more]
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────────┐ ┌──────────────┐
│ DECLINED │ │ Income? │ │ Income? │
│ │ └──────┬───────┘ └──────┬───────┘
│ Limit: 0 │ │ │
│ Rate: - │ ┌──────┴──────┐ ┌──────┴──────┐
│ Reason: │ [Under $50K] [Over $50K] [Under $75K] [Over $75K]
│ Poor │ │ │ │ │
│ Credit │ ▼ ▼ ▼ ▼
└──────────┘ ┌─────────┐ ┌─────────┐ ┌────────┐ ┌────────┐
│ MANUAL │ │ Debt │ │APPROVED│ │APPROVED│
│ REVIEW │ │ Ratio? │ │ │ │ │
│ │ └────┬────┘ │Limit: │ │Limit: │
│Limit: 0 │ │ │$10,000 │ │$25,000 │
│Rate: - │ ┌────┴────┐ │Rate: │ │Rate: │
│Reason: │[Over 40%] [40% or less]│ 12% │ │ 8% │
│Low Inc. │ │ │ └────────┘ └────────┘
└─────────┘ ▼ ▼
┌────────┐ ┌────────┐
│DECLINED│ │APPROVED│
│ │ │ │
│Limit: 0│ │Limit: │
│Rate: - │ │$5,000 │
│Reason: │ │Rate: │
│High │ │ 15% │
│Debt │ └────────┘
└────────┘
Evaluation Example:
For inputs: CreditScore = 650, AnnualIncome = $65,000, ExistingDebt = $15,000
- Root: Credit Score? → 650 is in range 580-699 → Follow middle branch
- Node 2: Income? → $65,000 >= $50,000 → Follow right branch
- Node 3: Debt Ratio? → $15,000 / $65,000 = 23% → 23% is less than or equal to 40% → Follow right branch
- Leaf: APPROVED, Limit: $5,000, Rate: 15%
Example: Support Ticket Routing Tree
Name: TicketRoutingDecision
Inputs:
TicketType(Option Set): Technical, Billing, General, ComplaintCustomerTier(Option Set): Enterprise, Business, IndividualSeverity(Option Set): Critical, High, Medium, LowProductLine(String): Which product the ticket concerns
Outputs:
AssignedTeam(String): Which team handles the ticketPriority(Integer): Priority level (1-5)SLAHours(Integer): Hours to respondEscalationPath(String): Who to escalate to if needed
Tree Structure:
┌───────────────┐
│ Customer Tier?│
└───────┬───────┘
│
┌───────────────────────┼───────────────────────┐
│ │ │
[Enterprise] [Business] [Individual]
│ │ │
▼ ▼ ▼
┌───────────┐ ┌──────────┐ ┌──────────┐
│ Severity? │ │TicketType│ │TicketType│
└─────┬─────┘ └────┬─────┘ └────┬─────┘
│ │ │
┌────┴────┐ ┌──────┴──────┐ ┌──────┴──────┐
[Critical] [Other] [Technical] [Other] [Complaint] [Other]
│ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│Escalate│ │Premium │ │Tech │ │General │ │Customer│ │Self- │
│Team │ │Support │ │Support │ │Support │ │Success │ │Service │
│ │ │ │ │ │ │ │ │ │ │ │
│Pri: 1 │ │Pri: 2 │ │Pri: 3 │ │Pri: 3 │ │Pri: 2 │ │Pri: 4 │
│SLA: 1hr│ │SLA: 4hr│ │SLA: 8hr│ │SLA: 24h│ │SLA: 24h│ │SLA: 48h│
└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘
Try It Live
Watch how inputs are consumed one at a time as the tree traverses — each decision node pulls exactly the value it needs, marks it used, then moves to the next. Hit Reset to walk it yourself, or let it run.
Decision Table vs. Decision Tree
| Aspect | Decision Table | Decision Tree |
|---|---|---|
| Structure | Flat, tabular | Hierarchical, flowchart |
| Evaluation | All conditions per decision | Conditions along path |
| Best for | Many independent decisions | Sequential decision-making |
| Readability | Easy to scan all decisions | Easy to follow logic path |
| Maintenance | Add/remove rows | Restructure branches |
| Visualization | Spreadsheet-like | Flowchart |
Choose Decision Table when:
- Decisions are largely independent
- You need to see all decisions at once
- Business users prefer tabular format
- Decisions can be easily expressed as condition combinations
Choose Decision Tree when:
- Decisions naturally follow a sequence
- Different paths require different questions
- You want to visualize the decision flow
- Some conditions only apply in certain contexts