Math Fundamentals18 sections · 814 units
Open in Course

Valid Triangle - Algorithm

(Pseudocode walkthrough)

1.1. Sort the three sides in ascending order: a ≤ b ≤ c 2.2. Check if a + b > c 3.3. If true, return valid 4.4. If false, return invalid

Example: sides [3, 4, 5]. After sorting: 3, 4, 5. Check 3 + 4 > 5? Yes (7 > 5), so valid.

Example: sides [1, 2, 10]. After sorting: 1, 2, 10. Check 1 + 2 > 10? No (3 < 10), so invalid.