
238
10 Data types anD structures
10 Data types and structures
In this chapter, you will learn about
★ basic data types, and how to select and use them
★ two different data structures: records and arrays
★ how to handle text files consisting of many lines, using pseudocode
★ three different abstract data types (ADTs): stacks, queues and
linked lists.
WHAT YOU SHOULD ALREADY KNOW
Try this activity to see if you can use one-
dimensional arrays before you read the first part
of this chapter.
Write an algorithm, using pseudocode, to find
the largest and smallest of five numbers.
The numbers are to be input with appropriate
prompts, stored in an array, and the largest
and smallest are to be output with appropriate
messages. If you haven’t used an array before
store the values in five separate variables.
Key terms
Data type – a classification attributed to an item of data,
which determines the types of value it can take and how
it can be used.
Identifier – a unique name applied to an item of data.
Record (data type) – a composite data type comprising
several related items that may be of different data
types.
Composite data type – a data type constructed using
several of the basic data types available in a particular
programming language.
Array – a data structure containing several elements of
the same data type.
Index (array) – a numerical indicator of an item of
data’s position in an array.
Lower bound – the index of the first element in an
array, usually 0 or 1.
Upper bound – the index of the last element in an array.
Linear search – a method of searching in which each
element of an array is checked in order.
Bubble sort – a method of sorting data in an array into
alphabetical or numerical order by comparing adjacent
items and swapping them if they are in the wrong order.
File – a collection of data stored by a computer
program to be used again.
Abstract data type (ADT) – a collection of data and a set
of operations on that data.
Stack – a list containing several items operating on the
last in, first out (LIFO) principle.
Queue – a list containing several items operating on the
first in, first out (FIFO) principle.
Linked list – a list containing several items in which
each item in the list points to the next item in the list.
10.1 Data types and records
Any computer system that is reusable needs to store data in a structured
way so that it can be reused in the future. One of the most powerful tools in
computer science is the ability to search large amounts of data and obtain
results very quickly. This chapter introduces data structures that enable
effective and efficient computer-based storage and searching to take place.
457591_10_CI_AS & A_Level_CS_238-263.indd 238 26/04/19 7:35 AM