12 Data Structure

Nov 10, 2019

Hello SCIE programmers, this is Jack.This article sheds light on the basic data structure in IGCSE.

12.1 Overall of data structure

Data structure is a way to store information in computers.There are generally four types of data structure:

LINEAR STRUCTURE

TREE

GRAPH

SET

In IGCSE, we only talk about one kind of structure in linear structure. That is array.

12.2 What is an array

Array can be understood as a kind of table.It is similar to the concept of series in math.For example, in math we can record a series as aiai​, where a1a1​ means the first element in the series aa.Whilst in programming, it can be written as a[i]a[i].
In conclude, an array is made up of its identifier(aa) and its index (ii).

12.3 How to declare an array

We can use
DECLARE : ARRAY[] OF
to declare an array.
For example, we want to have an array that can store 50 students id number.
DECLARE StudentId: ARRAY[50] OF INTEGER
Another example, we want to have an array that can store 50 students’ name.
DECLARE StudentName: ARRAY[50] OF STRING
And another example, we want to have an array that can store whether 50 students passed the exam or not.
DECLARE StudentPassed: ARRAY[50] OF BOOLEAN

NOTE:

Be careful of the datatype when declaring an array.

12.4 How to use an array

12.4.1 ASSIGN VALUES TO AN ARRAY

Let’s say you have an array called Name.
DECLARE Name: ARRAY[50] OF STRING
The whole array can be seen as:

123……50
‘ ‘‘ ‘‘ ‘‘ ‘

(‘ ‘ means empty)
You want the first element in the array to be your name.
You can just do:

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.