Last updated at October 28, 2026 by Teachoo
Transcript
Data Structures While executing the GCD algorithm, we need to keep several pieces of information: For gcd (m, n) Giving these values names allows us to refer to them precisely. For example: Name | What it stores m | First input number n | Second input number x | Divisor currently being examined divisors-of-m | List of Divisors of the first number divisors-of-n | List of Divisors of the second number common-divisors | List of Divisors found in both lists “For each x in divisors-of-m…” is much clearer than repeatedly saying: “Take the next number from the collection of factors of the first input…” What is a data structure? A data structure is a way of organising information so that an algorithm can store and use it. A list is one example. For instance: [1, 3, 5, 15, 25, 75] stores several numbers in a particular order. Why does the organisation matter? Compare these lists: A = [1, 3, 5, 15, 25, 75] B = [25, 1, 75, 5, 15, 3] They contain the same numbers. But: In A, the last entry is greatest because the list is increasing. In B, the last entry is 3, so we cannot use that shortcut. The way information is organised can make an operation simpler (Or it can make an assumed shortcut incorrect)