Lesson 101 — Testing Algorithms and Describing How They Work
Strand: Space | Descriptor: AC9M8SP04 | Duration: 45 minutes
Equipment: rulers, protractors (for the warmup construction).
Learning Intentions
- To test a congruency-checking algorithm systematically, including edge and invalid cases.
- To describe how an algorithm works using plain language, a flowchart, and pseudocode.
Success Criteria
I can:
- Trace a congruency-checking algorithm step by step for given triangle data.
- Choose test cases that probe an algorithm’s correctness, including an edge case that exposes a hidden flaw.
- Diagnose a fault and propose the smallest fix that corrects it.
- Represent an algorithm in three ways: plain language, flowchart, and pseudocode.
Warmup
(5 minutes — construct and compare, pairs with ruler and protractor)
Draw an angle of
. Along one arm, mark a point cm from the vertex. From that point, use your compass (or ruler, swinging an arc) to find a point on the other arm exactly
cm away. You should find two different places it can land. Draw both possible triangles.
- Do both triangles have a
angle, an cm side and a cm side? - Are the two triangles congruent to each other?
- What does this tell you about “two sides and an angle” as a congruence test?
Answers: 1. Yes — both. 2. No — they are different shapes (one has an acute third angle, one obtuse). 3. “Two sides and an angle” is not enough to guarantee congruence unless the angle is the one included between the two given sides (SAS), or the triangle is right-angled (RHS). This is the classical ambiguous case.
Why this matters today: in Lesson 100 your group designed an algorithm to test for congruency using SSS, SAS, AAS and RHS. Today we test it — and this ambiguous case is exactly the kind of edge case that exposes a hidden fault.
Activities
Activity 1 — Explicit Instruction: Three Ways to Represent an Algorithm (13 min)
An algorithm can be written in any of three equivalent forms. Learning to move between them is today’s core skill.
| Form | What it looks like | Best for |
|---|---|---|
| Plain language | Numbered steps, decisions as questions with both branches | Explaining to a person |
| Flowchart | Rectangles (instructions), diamonds (decisions), arrows (paths) | Seeing the shape of the logic at a glance |
| Pseudocode | IF … THEN … ELSE IF … ELSE … STOP, indented | Precision; closest to real code |
I do — the class’s draft congruency algorithm from Lesson 100 (Algorithm C), in plain language:
- Do all three sides of triangle 1 equal all three sides of triangle 2, in matching order? Yes → congruent by SSS. Stop.
- No → do two sides and an angle of triangle 1 equal two sides and an angle of triangle 2? Yes → congruent by SAS. Stop.
- No → do two angles and a corresponding side match? Yes → congruent by AAS. Stop.
- No → are both right-angled, with the hypotenuse and one other side matching? Yes → congruent by RHS. Stop.
- No → not proven congruent. Stop.
The same algorithm as a flowchart (rectangles = instructions, diamonds = decisions):
START
|
v
<Same three sides, SSS?>
Yes | | No
v v
[Congruent: SSS] <Two sides + an angle match?>
STOP Yes | | No
v v
[Congruent: SAS?] <Two angles + a side match?>
STOP Yes | | No
v v
[Congruent: AAS] <Right angle, hyp. + side match?>
STOP Yes | | No
v v
[Congruent: RHS] [Not proven]
STOP STOP
The same algorithm as pseudocode:
INPUT: two triangles, T1 and T2
IF all three sides of T1 match all three sides of T2 THEN
OUTPUT "congruent (SSS)"; STOP
ELSE IF two sides and an angle of T1 match two sides and an angle of T2 THEN
OUTPUT "congruent (SAS)"; STOP
ELSE IF two angles and a side of T1 match two angles and a side of T2 THEN
OUTPUT "congruent (AAS)"; STOP
ELSE IF T1 and T2 are right-angled AND hypotenuse and one side match THEN
OUTPUT "congruent (RHS)"; STOP
ELSE
OUTPUT "not proven congruent"; STOP
END IF
We do — trace all three forms together using the warmup’s two triangles (sides
(Expected: all three forms reach “congruent by SAS” — but we already showed the two triangles are different shapes. The algorithm has a fault, and it is the same fault in every representation, because the three forms describe the same logic.)
Activity 2 — Test, Diagnose, Fix (14 min)
Pairs. Build a test table for Algorithm C, find the fault, fix it, and re-test.
Test table — complete it, using the four kinds of test case from your Lesson 100 work:
| Test case | Kind | Expected | Actual (trace Algorithm C) | Pass? |
|---|---|---|---|---|
| typical | congruent (SSS) | |||
| typical | congruent (SAS) | |||
| edge | not congruent | |||
| typical | congruent (RHS) | |||
| Only one side given for each triangle | invalid | cannot decide |
- Run each case through Algorithm C (any of the three forms). Fill in “Actual” and “Pass?“.
- State the fault precisely: which step is too generous, and why?
- Propose the smallest fix — one word or phrase changed.
- Re-test the edge case against your fixed algorithm.
Socratic scaffolding for pairs who are stuck on naming the fault:
| Prompt | Purpose |
|---|---|
| Understand: what does step 2 currently check? | ”Two sides and an angle” — any angle, anywhere. |
| What did the warmup prove about that? | Two different triangles can share two sides and a non-included angle. |
| Devise a plan: what extra condition would rule out the warmup’s bad case? | The angle must sit between the two given sides. |
| Carry it out: rewrite step 2 with that condition. | ”Two sides and the included angle.” |
| Look back: does the fixed step still accept the true SAS case? | Yes — check the typical test case again; it still passes. |
The fix, stated for the board: replace “two sides and an angle” with “two sides and the included angle” in step 2. This single word is the difference between a valid congruence test and the ambiguous case.
Activity 3 — You Do: Describe the Fixed Algorithm (8 min)
Individually, then swap with a partner to check.
Write the fixed Algorithm C in all three forms: plain language, flowchart (a labelled sketch is fine), and pseudocode.
Then write a three-sentence description answering:
- What does this algorithm do?
- What does the “included angle” condition contribute, and why is it necessary?
- What can it not decide? (Hint: what if none of SSS, SAS, AAS, RHS match — does that prove the triangles are not congruent?)
Key point for the debrief: reaching “not proven congruent” does not mean the triangles are definitely different — it means this algorithm found no valid match. This is the same “testing cannot prove correctness” idea from earlier algorithm work, applied to an algorithm’s output, not just its design.
Checks for Understanding
(5 minutes — exit ticket, collected)
- Trace the fixed algorithm for:
has sides cm, cm with an included angle of ; has sides cm, cm with an included angle of . What is the output? - Why was “two sides and an angle” (without “included”) a faulty condition? Give the type of test case that exposed it.
- In your own words, what is the difference between a flowchart and pseudocode for the same algorithm?
- Reasoning. A triangle pair reaches “not proven congruent” in the fixed Algorithm C. Explain why this does not prove they are non-congruent.
Answers: 1. Congruent by SAS (the angle is included between the two given sides); 2. It accepted the ambiguous SSA case; an edge test case (two triangles sharing two sides and a non-included angle but different shapes) exposed it; 3. Both describe identical logic — a flowchart shows the shape of the branching visually with boxes and arrows, while pseudocode states each step and condition precisely in words close to real code; 4. The algorithm only checks four specific tests (SSS, SAS, AAS, RHS); a triangle pair might be congruent by some correspondence the algorithm did not check correctly, or might genuinely differ — “not proven” only means the algorithm’s tests did not succeed, not that congruence is impossible.
Common Misconceptions
| Misconception | How to pre-empt it |
|---|---|
| ”Two sides and any angle” is a valid congruence test. | The warmup’s physical construction shows two distinct triangles from the same SSA data. |
| A flowchart and pseudocode describe different algorithms. | Trace the same input through all three forms side by side; the outputs must match. |
| ”Not proven congruent” means “proven not congruent”. | Exit Q4; distinguish absence of proof from proof of absence. |
| RHS is just a special case of SSA, so SSA should always work. | RHS works only because the right angle plus the hypotenuse pins the triangle down uniquely — ordinary SSA has no such constraint. |
| Believing the smallest fix must be a whole rewritten step. | The fix here is one qualifying word: “included”. |
| Assuming a flowchart needs images to exist. | Model that indented text with arrows is a valid flowchart notation for this course. |
Enrichment — Competition-Style Problems
E1 (Kangaroo style). Two triangles share two equal sides and a
Answer
Yes — if the
E2 (AMC Junior style). An algorithm outputs “congruent by AAS” whenever two angles match, without checking that a side also matches. Give a counterexample showing this is unsafe.
Answer
Any two triangles with the same two angles but different sizes are similar, not congruent — e.g. a
E3 (Challenge). Write pseudocode for a similarity check (AA is enough) and explain in one sentence why it needs fewer conditions than the congruency algorithm.
Answer
IF two angles of T1 equal two angles of T2 THEN
OUTPUT "similar (AA)"; STOP
ELSE
OUTPUT "not proven similar"; STOP
END IF
Similarity only requires matching shape (angles), not matching size (sides), so it needs one condition instead of four.
E4 (Challenge). A tester runs Algorithm C (fixed) on
Answer
False. Twenty tests, however carefully chosen, are a finite sample of infinitely many possible triangle pairs. Testing can reveal faults but never prove their total absence — only a general logical argument (a proof) that covers every case could do that.
Homework
- Trace the fixed Algorithm C for:
sides ; sides . State the congruence test used. - Trace the fixed Algorithm C for:
has angles and included side cm; has matching angles and side. State the output. - Explain, using the warmup construction, why “SSA” is generally unsafe as a congruence test.
- Convert this plain-language step into pseudocode: “Are all four sides and all four angles of quadrilateral 1 equal to quadrilateral 2? Yes → congruent. No → not proven congruent.”
- Draw a simple flowchart (boxes, diamonds, arrows) for the pseudocode in Q4.
- A triangle pair reaches “not proven congruent” in Algorithm C. Suggest one additional valid test (not SSS, SAS, AAS, or RHS) that a more complete algorithm could check. (Hint: think about what other equal-arrangement of sides/angles might work.)
- Reasoning. Explain, in three sentences, why an algorithm’s plain-language, flowchart and pseudocode forms must always trace to the same output for the same input.
- Challenge. RHS is really SSA with an extra condition. State the extra condition, and explain precisely why it removes the ambiguity that ordinary SSA suffers from.
Answers: Q1 — congruent by SSS. Q2 — congruent by AAS (two angles and a corresponding side match — this is the ASA case, but since matching two angles automatically matches the third by the angle sum, the algorithm’s AAS step catches it too; step 2, SAS, does not apply here since only one side is given, not two). Q3 — the same two sides and non-included angle can form two different triangles (one with an acute third angle, one obtuse), as constructed in the warmup, so the data does not pin down a unique triangle. Q6 — e.g. ASA (two angles and the included side) is already covered by AAS in most courses, but students may suggest checking a different valid correspondence order, or note that no further standard test exists beyond SSS/SAS/AAS/RHS for triangles. Q8 — the extra condition is that the triangle contains a right angle and the known side is the hypotenuse; because the hypotenuse is the longest side and is opposite the right angle, only one triangle shape satisfies the given lengths, removing the two-solution ambiguity that ordinary SSA has.