Mapping Decision Paths Visually, Explained with Code Examples

UPI Study › Courses › C++ Programming › Free lessons › Lesson 4.3 Free with a free account

Mapping Decision Paths Visually

C++ Programming · Chapter 4: Decision MakingSection 4.3 · lesson 23 of 84video coming soon

← Layering Multiple ConditionsNext lesson: Routing Execution With if and else →

Earn 3 college credits for C++ ProgrammingRecommended for credit by NCCRS · Computer Science 242 · self-paced · one payment, lifetime access

In this lesson

Drawing the rules before writing conditional code.

  • Use the five standard flowchart symbols
  • Draw single, chained and nested decisions
  • Build a decision table for several conditions
  • Check rules for completeness and overlap

Transcript

Everything said in the video, section by section (1,169 words). Read along, or search it.

Opening Problem

Prose Rules Hide Missing Paths

A set of rules written as prose looks complete long before it is. Take one: members get a discount. It sounds finished. Now draw it. The question, the yes path, and then the no path: where does it go? There's an arrow with nothing on the end of it. That's the whole value of the exercise. A forgotten case is caught early, by paper, rather than late, by someone using the finished program.

Flowchart Symbols

Five Shapes and Their Meanings

Five standard symbols are used, and their shapes carry the meaning, so a reader knows what a box does before reading a word in it. A rounded terminator marks the start and the ends. There's exactly one start, though there can be several ends. A rectangle is a process: one action, one arrow in, one arrow out. A diamond is a decision, a yes or no question, with exactly two exits, both labeled. A parallelogram marks input or output: where the program touches the outside world. And a small lettered circle is a connector, joining two points that won't fit side by side. One more rule: a question with three answers is really two questions. And flow lines always carry arrowheads, because direction is part of the meaning.

Single Decision

One Question, Two Drawn Paths

The smallest useful shape is one question with two paths. It comes in two forms. One-sided: is the order over 2,000? If yes, add free delivery. If no, nothing happens. That path carries no action, but it still exists, and it must be drawn. Two-sided: the same question, but yes gives a delivery charge of 0, and no gives 90. Both paths act, then rejoin. Is that last rule right? Nobody can say, until it's drawn. A path where nothing happens is still a decision you made. Drawing it forces you to say so, and a reviewer can agree or disagree. An undrawn path looks exactly like an overlooked one, and that's precisely the difference that matters when something later turns out wrong.

Chain Pattern

Chained Questions: First Yes Wins

Many rules are a list of alternatives, exactly one of which applies. These are drawn as a chain. Is the weight up to 1 kilogram? Yes, and the fee is 50. No, and the next question: is it up to 5 kilograms? Yes, and the fee is 120. No, and the fee is 250: the only answer left. The first matching question wins. Once a yes is taken, no later question is asked. And the final no needs no test of its own. It covers whatever survived every question above it, so no case falls out of the bottom. Quick check. A 900 gram parcel passes both tests. Which fee does it pay? Pause, and decide. Fifty, because that question is asked first. Once a yes is taken, nothing below it is asked. That makes order part of the meaning. Reorder the chain, asking the 5 kilogram question first, and the same parcel is charged 120.

Nesting Pattern

Inner Questions Depend on Outer Answers

Nesting is a different arrangement entirely. The second question only means something when the first was answered a particular way. Is the customer a member? If yes, then ask: is the order over 5,000? Yes gives a 20 percent discount. And no gives 10 percent. If they're not a member, the discount is 0, and the order size is never even asked. For a non-member, the size of the order decides nothing at all. That's what separates nesting from a chain: the inner question is only reached when its branch is taken.

Comparison

Choosing Between Chains and Nesting

So which arrangement fits which rule? A chain sounds like: either this, or this, or this. Its questions are alternatives at the same level. Nesting sounds like: if this, then it depends on that as well. The inner question only makes sense given the outer answer. Order matters in both, differently. Reordering a chain changes which rule wins. Swapping outer and inner changes which cases are considered at all. A chain gives one outcome per question, plus the final no. Nested questions multiply: two questions give up to four outcomes. And watch the warning signs: a chain longer than about 5 questions, or nesting more than 2 or 3 deep, wants a decision table instead.

Decision Tables

Counting Combinations Instead of Drawing Them

Drawings stop helping once several conditions combine. Four conditions give sixteen paths, and a chart of sixteen paths clarifies nothing. So use a decision table: one row per combination, with the conditions across the top, and the action at the end. Here: is the customer a member, is the order over 5,000, was a coupon used? All three yes: 25 percent. Member, big order, no coupon: 20. Member, small order, with a coupon: 15. Member alone: 10. Not a member, but a big order and a coupon: 10. Big order alone: 5. Coupon alone: 5. And none of them: no discount. Every row has an action, and no situation appears twice. The table's virtue is arithmetic. With 3 yes or no conditions, there are exactly 2 times 2 times 2 combinations: 8. So you know in advance how many rows to expect. A missing case is something you count, not something you have to notice. Ask someone for these rules, and you get four sentences. Hand them the table, and the disagreements surface, usually on rows 5 and 7, the combinations nobody had considered. Once everyone agrees, a table can be shortened: where a condition makes no difference, a dash means either answer. But only after it's checked, never instead of building it.

Testing Rules

Gaps and Overlaps at Boundaries

Two properties are worth testing deliberately, because both failures are invisible in prose, and obvious on a line. Completeness: does every situation have an answer? Count the combinations you should have, and compare with the ones you wrote. For ranges, that means they must touch, with no space between. Both faults live at the boundary. Under 100 is standard, over 100 is bulk. An order of exactly 100 matches no rule at all: a gap. Mutual exclusivity: can two rules claim the same situation? If they disagree, the outcome depends on which is tested first, and that order is often accidental. Now say 100 or less is standard, and 100 or more is bulk. Exactly 100 matches both, and whichever rule is asked first silently wins. That's an overlap. Most disputes about what a program should do, turn out to be about a single value, at the edge of a range. Nobody hears it aloud. Everybody sees it on a line.

Quick Check

Find the Fault at 500

Quick check. Under 500 pays standard. Over 500 pays reduced. Name the fault, the value it affects, and a repair. Pause, and think.

Answer

A Gap Repaired by Owning the Boundary

A gap at exactly 500. Neither rule claims it. The repair: let exactly one side own the boundary. 500 or less pays standard.

Key Takeaways

Two Exits, Chains, Nesting, Tables, Boundaries

To summarize. A decision always has exactly two labeled exits, including any path where nothing happens. In a chain, the first yes wins. In nesting, the inner question may never be asked. With several conditions, use a table of 2 to the n rows, so completeness becomes counting. And check every set of rules for gaps and overlaps, especially at the boundaries.

About C++ Programming at UPI Study

C++ Programming (Computer Science 242) is a self-paced online course of 84 video lessons in 11 chapters, from your first program to decisions, loops, arrays, functions, classes, files, pointers and inheritance. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Why take it here

Why students take C++ Programming with UPI Study

Your first real programming languageC++ teaches how programs really work: variables, control flow, functions, memory and objects. It is the base for data structures, algorithms, systems and game programming, and for most computer-science degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

C++ Programming carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About Mapping Decision Paths Visually

What are the five standard flowchart symbols and what does each one mean?
The five symbols are the rounded terminator, the rectangle, the diamond, the parallelogram, and the lettered circle. The terminator marks the start and the ends. A rectangle is one process step, a diamond is a yes/no decision with two labeled exits, a parallelogram is input or output, and a small circle is a connector. Flow lines carry arrowheads.
What is the difference between chained and nested decisions in a flowchart?
A chained decision lists alternatives at the same level, and the first yes wins, while a nested decision asks an inner question only after the outer one is answered a certain way. In a shipping chain, a 900 gram parcel taking the "up to 1 kilogram" branch never reaches later questions. In a nest, a non-member is never asked about order size.
How do I build a decision table for several conditions?
List one row for every combination of yes/no answers, put the conditions across the top, and put the action in the last column. With n yes/no conditions you need 2 to the n rows, so three conditions give 2 times 2 times 2, or 8 rows. Counting the rows you wrote tells you whether a case is missing.
How do I check decision rules for gaps and overlaps?
Test completeness and mutual exclusivity, especially at range boundaries. If one rule says under 100 and another says over 100, exactly 100 matches neither, which is a gap. If the rules say 100 or less and 100 or more, then 100 matches both, which is an overlap. Fix either by letting exactly one side own the boundary value.

About the C++ Programming course

How many college credits is C++ Programming?
C++ Programming (Computer Science 242) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does C++ Programming cost and what is included?
$250, paid once, with lifetime access: all 84 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does C++ Programming take?
It is self-paced with no deadlines. The 84 lessons total about 0 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in C++ Programming.

84 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

C++ Programming
3 credits · NCCRS
Enroll →