- 53 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'Data Structures [1]' - tanisha-blackwell

**An Image/Link below is provided (as is) to download presentation**

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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Arrays

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

Tue 230

Wed 180

Thu 270

Fri 120

(All of data type Integer)

Data Structures 1.

In Visual Basic…

Dim Sales(5) As Integer

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

Eg.

Mon 240

Tue 230

Wed 180

Thu 270

Fri 120

- Sales(4)

Data Structures 1.

Two-dimensional Arrays

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

Eg. Sales figures for John, Mary and Sue:

John Mary Sue

Mon240 420 140

Tue230 380 190

Wed180 400 210

Thu270 360 240

Fri120 320 190

Sales(4,2)

Data Structures 1.

Three-dimensional Arrays

- 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 1 John Mary Sue

Mon240 420 140

Tue230 380 190

Wed180 400 210

Thu270 360 240

Fri120 320 190

Item 2 John Mary Sue

Mon440 440 120

Tue530 380 390

Wed480 440 280

Thu670 365 540

Fri150 310 490

Item 3 John Mary Sue

Mon210 430 120

Tue130 280 190

Wed120 100 220

Thu270 320 143

Fri120 220 295

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.

Records

- 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.

In Visual Basic…

Structure PupilType

Dim PupilName As String

Dim Form As String

Dim DOB As Date

Dim ExamMark As Integer

End Structure

Data Structures 1.

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.

Arrays of Records

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.

Download Presentation

Connecting to Server..