Download arrays & data structures

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Array data structure wikipedia , lookup

Transcript
A-Level Computing
data structures
Objectives
•
•
•
Know how the ways data is stored and organised
in a computer system
Understand how data can be manipulated and
referenced in an array
Be able to explain the need for each type of data
structure
Data Arrays
•
•
•
A data structure is a way of organising data so
that it can be efficiently processed
An array is a type of data structure, and appears
as a table or list
Used to hold data (e.g. names) of the same type
Data Arrays
•
•
The data items in an array are called its
elements.
Each element has a subscript to identify it
Subscript
Name
0
Grant
1
Tim
2
Jake
3
Ben
4
Liam
Data Arrays
•
A one-dimensional array is an array where each
item is identified by one subscript.
•
Items are identified as: Name[2] = ‘Jake’
•
If Name[n] = Grant....what is n?
Data Arrays
•
A two-dimensional array is an array where two
subscripts are needed to identify each element.
January February
March
Tim
£450
£320
£520
Grant
£430
£300
£200
Jake
£340
£285
£410
Ben
£120
£450
£400
Liam
£250
£310
£375
Helen
£475
£300
£280
sales[2,1] =
£285
Data Arrays.....1-D
Score
Steve
45
Mark
23
Kelly
67
Gary
35
Data Arrays.....2-D
ICT
Maths
English
Art
Steve
45
56
45
67
Mark
23
62
43
45
Kelly
67
17
36
37
Gary
35
34
27
56
Data Arrays.....3-D!
Year 7 Scores
ICT
Steve
Mark
Kelly
Gary
Maths English
45
Art
45
67
Year 8 Scores
23
62
43
45
ICT
Maths English
Art
67
17
36
37
Steve
56
76Year 967
34
Scores
35
34
27
56
Mark
45
34
55 English
56
ICT
Maths
Kelly
Gary
56
Art
76
Steve
45
Mark
17
89
12
78
36
89
27
93
89
78
76
67
98
Kelly
67
56
68
89
Gary
47
12
27
76
78
Records
•
•
•
•
A record consists of a number of fields
A field consists of a single data item and these
may be of different types
In a program, the field name and data type need
to be declared
For example a record may consist of four fields....
Records
Field
Data Type
Student id
Integer
Name
String
Class
String
Exam Average
Real