OCR A-Level Computer Science H446
Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation
Software Development
Types of Programming Language
Exchanging Data
Networks
Web Technologies
Data Types and Number Representation
Data Structures
Boolean Algebra
Legal, Moral, Cultural and Ethical Issues
Elements of Computational Thinking
Problem Solving and Programming
Algorithms
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.
What is the key difference between an array and a record?
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
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
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
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
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
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
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.
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.