Skip to content
Marlbridge

Flashcards · 9618 · AS Topic 10

Data Types and Structures (AS Level) flashcards

18 cards on AS Topic 10, subtopics 10.1 to 10.4. Pick a subtopic or study them all.

Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.

All 18 cards

For a quick read-through or printing. Cover the right-hand side to test yourself.

10.1 Data Types and Records

Which basic data types does 9618 pseudocode use?
INTEGER, REAL, CHAR, STRING, BOOLEAN and DATE.
How do you declare a variable and a constant in 9618 pseudocode?
DECLARE Total : INTEGER CONSTANT VAT = 0.2 A constant’s value is fixed when it is declared and cannot be changed by the program.
What is a record data type?
A composite data type made of several fields, which can be of different data types, describing one item (such as one student).
How do you define a record type in 9618 pseudocode?
TYPE TStudent DECLARE Name : STRING DECLARE Age : INTEGER ENDTYPE Then DECLARE Pupil : TStudent and use dot notation: Pupil.Name ← "Ali"

10.2 Arrays

What is an array?
A fixed-size data structure holding elements of the same data type under one identifier, each reached by its index.
How do you declare 1D and 2D arrays in 9618 pseudocode?
DECLARE Names : ARRAY[1:30] OF STRING DECLARE Grid : ARRAY[1:3, 1:5] OF INTEGER The bounds give the lower and upper index of each dimension.
How does a linear search work?
Check each element in turn from the start until the item is found or the end of the array is reached. The data need not be sorted.
How does a bubble sort work?
Compare each pair of adjacent elements and swap them if they are in the wrong order. Repeat passes until a pass makes no swaps.
How can a bubble sort be made more efficient?
Use a flag to stop as soon as a pass makes no swaps, and reduce the number of comparisons by one after each pass, since the largest value is already in place.

10.3 Files

Why are files needed?
Data in variables is lost when a program ends. A file stores data permanently, so it can be read back by the program later or by other programs.
What are the three file modes for a text file in 9618 pseudocode?
READ, WRITE and APPEND, e.g. OPENFILE "Scores.txt" FOR READ. WRITE replaces any existing contents; APPEND adds to the end.
How do you read every line of a text file in 9618 pseudocode?
OPENFILE "Data.txt" FOR READ WHILE NOT EOF("Data.txt") READFILE "Data.txt", Line … ENDWHILE CLOSEFILE "Data.txt"
How do you write a line to a text file in 9618 pseudocode?
OPENFILE "Log.txt" FOR WRITE (or FOR APPEND) WRITEFILE "Log.txt", Line CLOSEFILE "Log.txt"

10.4 Introduction to Abstract Data Types (ADT)

What is an abstract data type (ADT)?
A collection of data together with a set of operations on that data, defined by what it does rather than how it is implemented.
How does a stack work?
Last in, first out (LIFO). Items are pushed onto and popped off the top. A top-of-stack pointer tracks the last item.
How does a queue work?
First in, first out (FIFO). Items join at the rear (enqueue) and leave from the front (dequeue), tracked by front and rear pointers. A circular queue reuses freed spaces.
What is a linked list?
A list of nodes, each holding data and a pointer to the next node. A start pointer gives the first node and a null pointer marks the end. Items can be inserted or deleted by changing pointers, without moving data.
How can a stack, queue or linked list be implemented using arrays?
Store the items in a 1D array and keep integer pointers (indices) for the top, front/rear or next node. A linked list also keeps a free list of unused array positions.