Mathematics I / Vectorised Computation and Libraries
Practice question · Fill in the blanks

Complete the reason vectorised code is faster.

A vectorised array operation beats an explicit loop because it ______.

Word bank: performs fewer arithmetic operations overall · hands the whole array to optimised compiled code · skips most of the elements · uses far less memory

Hints
  1. Count the additions each version performs, they are the same.
  2. The difference is in what executes them, not how many there are.
Show the answer

A vectorised array operation beats an explicit loop because it hands the whole array to optimised compiled code.

Why

The arithmetic is identical; the gain comes from replacing interpreted per-element work with compiled code that can process many elements per cycle. Believing that fewer operations are performed is the standard misunderstanding.

Read the lesson: Vectorised Computation and Libraries →

Practise Vectorised Computation and Libraries

The app has 5 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Vectorised Computation and Libraries