- 43 Views
- Uploaded on
- Presentation posted in: General

Data Structures [1]

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Data Structures [1]

CP1

Data Structures 1.

- All data must be the same data type….
- Eg. (Daily sales figures for John - to nearest £)
Mon240

Tue230

Wed180

Thu270

Fri120

(All of data type Integer)

Data Structures 1.

Dim Sales(5) As Integer

A one-dimensional array has one subscript to identify the element of the array.

Eg.

Mon240

Tue230

Wed180

Thu270

Fri120

- Sales(4)

Data Structures 1.

- Data must be the same type.
- A two-dimensional array has 2 subscripts.

Eg. Sales figures for John, Mary and Sue:

JohnMarySue

Mon240420140

Tue230380190

Wed180400210

Thu270360240

Fri120320190

Sales(4,2)

Data Structures 1.

- Data must be the same type.
- A two-dimensional array has 3 subscripts.

Eg. Sales figures for John, Mary and Sue for each of three different items…

Item 1JohnMarySue

Mon240420140

Tue230380190

Wed180400210

Thu270360240

Fri120320190

Item 2JohnMarySue

Mon440440120

Tue530380390

Wed480440280

Thu670365540

Fri150310490

Item 3JohnMarySue

Mon210430120

Tue130280190

Wed120100220

Thu270320143

Fri120220295

Data Structures 1.

- …and YES! In programming you can have Arrays with more than three dimensions…
- All data must be of the same data type
- An n-dimensional array would use n subscripts to identify each element.

Data Structures 1.

- Data may be of different types
- Eg. (Name, Form, DOB, Exam mark)
John Smith

12 T

12/04/85

65

(Text strings, a date and a number)

Data Structures 1.

Structure PupilType

Dim PupilName As String

Dim Form As String

Dim DOB As Date

Dim ExamMark As Integer

End Structure

Data Structures 1.

Structure PupilType

Dim PupilName As String

Dim Form As String

Dim DOB As Date

Dim ExamMark As Integer

End Structure

A variable Pupil can be declared as being of type PupilType, and the fields assigned…

Dim Pupil As PupilType

Pupil.PupilName = “John Smith”

Pupil.Form = “12T”

Pupil.DOB=“12.04.85”

Pupil.ExamMark = 65

Data Structures 1.

An array of records is sometimes called a TABLE.

Each record has a subscript…If this table was called Markbook, then

Markbook(4).ExamMark is 44.

Data Structures 1.