Learn › Class 9 › Mathematics › The World of Algorithms
Algorithms and flowcharts
Example 1: Euclid's algorithm for HCF(48, 18)
Open one step at a time. Try the next step yourself first.
- Step 1. Divide 48 by 18: remainder 12.
Show step 2
Divide 18 by 12: remainder 6.
Show step 3
Divide 12 by 6: remainder 0.
Show step 4
The last non-zero remainder is 6, so HCF = 6.
Example 2: Binary search for 37 in 5, 12, 20, 29, 37, 44, 51
Open one step at a time. Try the next step yourself first.
- Step 1. Middle value is 29. 37 is larger, so search the right half: 37, 44, 51.
Show step 2
Middle of that is 44. 37 is smaller, so search 37.
Show step 3
Found 37 after 3 comparisons.