levo

Data Structures

Arrays and records

  • 3 things to know
  • Component 01
Start revising · £5/month

Overview

Recall questions on one, two and three-dimensional arrays, calculating element addresses, why arrays give direct access, the limitations of arrays, records, and how arrays differ from records and are combined into arrays of records.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is a record?

Key term

What is the key difference between an array and a record?

Numbers

How many elements does an array declared as 2 by 3 by 4 hold?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is an array?

    Model answer

    An ordered, indexed collection of elements that are all of the same data type, held in a block of consecutive memory locations. It has a size fixed when it is created, and each element is reached by its index (position number) rather than by searching for it.

  2. 2

    A one-dimensional array is a row of values. What does a two-dimensional array give you, and how do you get at a single element?

    Model answer

    A two-dimensional array is a table: rows and columns. You reach a single element with two indices, conventionally the row first and the column second, for example grid[2][5] meaning row 2, column 5. It is the natural structure for anything grid-shaped, such as a spreadsheet, a board game, a seating plan or a black-and-white image.

  3. 3

    Describe what a three-dimensional array is and give a use for one.

    Model answer

    A three-dimensional array is effectively a stack of two-dimensional tables, so it needs three indices, for example cube[layer][row][column]. Uses include a three-dimensional game world or voxel model, a colour image where the third index selects the red, green or blue channel, or exam marks stored as [student][subject][term].

  4. 4

    How many elements does an array declared as 2 by 3 by 4 hold?

    Model answer

    24. The sizes of the dimensions multiply: 2 x 3 x 4 = 24 elements.

  5. 5

    Explain why an array can jump straight to element 500 without looking at the other 499.

    Model answer

    Because the elements are all the same size and stored contiguously, the computer can calculate the address of any element arithmetically rather than searching for it: address = base address + index x size of one element. That single calculation gives constant-time random access, which is the array's main strength.

  6. 6

    An array of 4-byte integers begins at address 2000 and is indexed from 0. What is the address of element 6?

    Model answer

    2024. Address = 2000 + (6 x 4) = 2000 + 24 = 2024. Note that if the array were indexed from 1 instead, you would use (6 - 1) x 4, giving 2020 - always check the base index.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Data Structures, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.