levo

Data Structures

Arrays and records

  • 3 things to know
  • Component 01

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz makes facts automatic

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

A0 + 0 gives 0.
B0 + 1 gives 1.
C1 + 1 gives 0 carry 1.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

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

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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