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 →
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.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take C++ Programming with UPI Study
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.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →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?
What is the difference between chained and nested decisions in a flowchart?
How do I build a decision table for several conditions?
How do I check decision rules for gaps and overlaps?
About the C++ Programming course
How many college credits is C++ Programming?
How much does C++ Programming cost and what is included?
Which universities accept UPI Study credits?
How long does C++ Programming take?
How are the exams done?
How do my credits reach my college?
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.
3 credits · NCCRSEnroll →