‹ Class 9 · Ch 11
The World of Algorithms · Principle 13 of 29

Organised information

Data structures

Stuck? Ask Guru

NCERT: 11.3 Data Structures

Think

More than numbers

Our gcd algorithm keeps more than single numbers: it keeps lists of numbers, named divisors-of-m and divisors-of-n, and they are always in ascending order.

How does keeping the common divisors in ascending order help?

What this lesson covers

The idea

A data structure, such as a list, organises information in a way that helps make an algorithm more efficient.

More than numbers

Our gcd algorithm keeps more than single numbers: it keeps lists of numbers, named divisors-of-m and divisors-of-n, and they are always in ascending order.

How does keeping the common divisors in ascending order help?

  • The gcd is simply the rightmost element: no search needed
  • It makes the lists shorter
  • It doesn't help at all

An ordered list

Watch the common-divisors list grow in order. Because it is organised, finding the gcd at the end takes no extra work.

Data structures

A data structure, such as a list, organises information in a way that helps make an algorithm more efficient.

When we run an algorithm, we compute intermediate values such as divisors-of-m and divisors-of-n. These are often more complicated than single numbers: here they are lists, arranged in ascending order. A list is an example of a data structure. (We will explore this idea in higher grades.)

Notes

A data structure, like an ordered list, organises information so that an algorithm can be more efficient.

Check yourself

Which of these is a data structure used in the gcd algorithm?

Because common-divisors is in ascending order, finding the gcd …

  • The list common-divisors — correct. Yes. A list is a data structure.
  • The number 75. 75 is a single value, the answer.
  • The word gcd. gcd is the name of what we compute.
  • takes no search: read the rightmost element — correct. Yes. The organisation does the work for us.
  • needs comparing every pair of elements. That would be needed for an unordered collection.
  • is impossible. It is easy: the rightmost element.