Data structures 1
This presentation is the property of its rightful owner.
Sponsored Links
1 / 10

Data Structures [1] PowerPoint PPT Presentation


  • 35 Views
  • Uploaded on
  • Presentation posted in: General

Data Structures [1]. CP1. 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 ). In Visual Basic…. Dim Sales(5) As Integer

Download Presentation

Data Structures [1]

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


Data structures 1

Data Structures [1]

CP1

Data Structures 1.


Arrays

Arrays

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


In visual basic

In Visual Basic…

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.


Two dimensional arrays

Two-dimensional Arrays

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


Three dimensional arrays

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

Mon240420140

Tue230380190

Wed180400210

Thu270360240

Fri120320190

Item 2JohnMarySue

Mon440440120

Tue530380390

Wed480440280

Thu670365540

Fri150310490

Item 3JohnMarySue

Mon210430120

Tue130280190

Wed120100220

Thu270320143

Fri120220295

Data Structures 1.


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

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 basic1

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.


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.


Arrays of records

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.


  • Login