SlideShare une entreprise Scribd logo
1  sur  38
LECTURE 2: DATA STRUCTURES
An array is a data structure consisting of a group of
elements that are accessed by indexing.
An array is a situation where a set of data items are
conveniently arranged into a sequence & referred to by
a single identifier.
 Each data item of an array is known as an element &
the elements are referenced by a common name
known as the array name
An array is a collection of objects of the same data
type, allocated contiguously in memory. Individual
objects in an array, called elements, are accessed by
their position in the array.
AN ARRAY
The position is given by an index, which is also
called a subscript.
An array facilitates the coding of repetitive
tasks by allowing the statements executed on
each element to be put into a loop that iterates
through each element in the array.
An array, also known as a vector or list (for
one-dimensional arrays) or a matrix (for two-
dimensional arrays)
ARRAYS
An Array is a variable.
It can hold a series of values, essentially, a list of
values.
An array provides the logical convenience of being
able to reference all its values by using the single
array name.
As a variable, an array is an area in memory,
random access memory (RAM) reserved under a
name, and referred to by name, into which values
can be assigned.
ARRAYS
An array is a structure that holds multiple
values of the same type.
 An array - known as a vector or list (for one-
dimensional arrays) or a matrix (for two-
dimensional arrays)
It is one of the simplest data structures.
Examples
E.g. Cartoons = (Popeye, Scooby Doo, Tom &
Jerry)
Data Structures = (Stacks, Queues, List)
Individual data items are referred to by stating
their position e.g. Cartoons [1] is Popeye
An array is a structure containing one or more
subdivisions each of which may contain data
TYPES OF ARRAYS
One Dimensional Array
Two Dimensional Array
a) One Dimensional Array
Within the array, subscripts are used to
indicate the individual elements, written as
integers within square brackets.
195.00 491.82 299.95 320.00
Thus credit [1] would be the first deposit in the
checking account; credit [2] would be the
second deposit and so on.
Credit Array:
[195.00] [491.82] [299.95] [320.00]
Debit Array:
14.79 52.25 44.7516.13
One Dimensional Array
The above diagrams shows a credit and
Debit Array in which
Credit [1] = 195.00, Credit [2] = 491.82
Credit [3] = 299.95
Similarly, Debit [1] =14.79, Debit [2] =52.25,
Debit [3] =16.13, Debit [4] =44.75, Debit [5]
= 114.21
One Dimensional Array
They have a single subscript and are called
one-dimensional arrays; often thought of
as lists.
In mathematics such arrays are often called
vectors.
A one dimensional array is therefore an
array having only one subscript & the
individual elements are of the same type.
EXAMPLE 2
To store the salaries of up to 50 employees in a
firm we can use an array called salary in which
salary [1], salary [2] … salary [50] are real
variables that will store the salaries of the first
employee, the second employee…up to the 50th
employee.
The array contains real elements and the
subscripts run over the integer sub range
[1………50].
b) Two Dimensional Array
A two dimensional array is a generalization of a
linear list, for example an m x n matrix.
The rows and column list essentially account
for two dimensional structure of a matrix.
An array contains a sequence of elements all of
the same element type.
 The element type can be any type, even an
array (but not the same array), thus we have an
array of arrays
EXAMPLE
c0 c1 c2 c3
r0 0 1 2 3
r1 1 2 3 4
r2 2 3 4 5
r3 3 4 5 6
r4 4 5 6 7
EXAMPLE
Here, we have an array with five rows and
four columns.
 It has twenty total elements.
 However we say it has dimension five by
four, not dimension twenty
EXAMPLE
We have a pay array containing 50 rows with 26
real elements on each row. Each row represents an
employee and each column a pay period i.e. ( a
two – dimensional array ).
Pay [1,1]Pay [1,2] Pay [1,3] ……Pay [1, 26]
Pay [2,1]Pay [2,2] Pay [2,3] ……Pay [2, 26]
Pay [3,1]Pay [3,2] Pay [3,3] ……Pay [3, 26]
: : : : :
Pay [50,1]Pay [50,2] Pay[50,3]………………………
Pay [50,26]
c) Parallel Arrays
As an application of one dimensional array, we
begin the construction of a payroll program to
read and display employees’ salaries for a small
business e.g.
Enter employees’ ID numbers and salaries
Employee # 1
ID Number: 11111
Salary: 222.22
Contd...
 Employee # 2
ID Number: 11112
Salary: 333.33

Employee # 3
ID Number: 11113
Salary: 444.44
Etc.
Example
The program will need to store a two – part
record for each employee, containing both the
integer employee number & ID– number salary.
An employee record is therefore
heterogeneous & cannot be stored entirely in
one array.
Instead we will use a pair of arrays, ID & salary
which are said to be parallel arrays, because
their subscripts track together: i.e. salary [I] & ID
[I] together make up the data record for the 1st
employee.
Example
Salary [1] Salary [2] Salary [3]
Example
ID [1] Salary [2] Salary [3]
Question
Class, What are the
Components of an
Array???
COMPONENTS OF AN ARRAY
An array consists of elements, data type,
subscript & the square brackets.
Arrays hold a series of data elements, usually
of the same size & data type.
The series could be of data types such as
integers, strings or even floats.
COMPONENTS OF AN ARRAY
Individual elements are accessed by their
position in the array.
The position is given by an index, which is
also called a subscript.
The index usually uses a consecutive range
of integers
CHARACTERISTICS OF ARRAYS
Homogeneous: They store one type of data
elements.
Cartesian: Arrays allow their access through
an index. This referencing is possible because
arrays have subscripts and elements that
enable access via index
CHARACTERISTICS OF ARRAYS
Subscripts: In Pascal the subscripts are
written as integers within square brackets thus
credit [1] would be the first deposit in the
checking account, credit [2] would be the
second deposit and so on.
Example
[1] = 195.00 and credit [2] = 491.82
Similarly,
Debit [1] = 14.79, debit [2] = 52.25
Credit array 195.00 491.82 299.95 320.27
Debit array 14.79 52.25 16.13 44.75
CHARACTERISTICS OF ARRAYS
We use subscripts to access the individual elements i.e.
in a one-dimensional array, it has only one subscript & is
imagined as a list or vector.
The elements are stored in sequence in memory
beginning with the address of the lowest-subscripted
element.
 A two dimensional array has two subscripts & is
imagined as a table with rows & columns.
Form the basis for several more complex data
structures, e.g. hash tables, stacks and
queues.
Arrays provide a very special way of sorting or
organising data in a computers memory
Arrays serves as parameters in computation
Arrays help reduce length of algorithm
FUNCTIONS OF ARRAYS
OPERATIONS ON ARRAYS
Creating an array: The create function produces a
new, empty array of the appropriate size.
 Assigning the array: Once an array has been
created a value from a field or variable, is then
assigned to an element of the array. The syntax
used is:
Array name {element number}:= value. Array
elements are numbered by their position in the
array, starting at one and going up.
Additionally, every array has zero element number.
OPERATIONS ON ARRAYS
Retrieving : Retrieve operation accepts an
array and an index.
This returns the value associated if the index is
valid, or error if the index is invalid.
Searching : Searching methods are designed
to take advantage of the organization of
information & thereby reduce the amount of
effort to either locate a particular item or to
establish that it is not present in a data set.
OPERATIONS ON ARRAYS
Sorting and Merging: Sorting & merging
provide us with a means of organizing
information to facilitate the retrieval of specific
data.
Field or variable: = array name {element
number}
OPERATIONS ON ARRAYS
Displaying arrays: To display the contents of
array on a form, you simply give an active
object capable of displaying an array
The contents of the array will then automatically
be displayed in that object. The objects that can
display the contents of an array are: Pop-up
Lists/Drop-down Lists, and Combo Boxes.
AN EXAMPLE????
APPLICATION OF ARRAYS
CLASS DISCUSSION
ADVANTAGES OF ARRAYS
Arrays permit efficient random access in
constant time making them most appropriate for
storing a fixed amount of data which will be
accessed in an unpredictable fashion.
 This means that the time taken to access a[i] is
the same for each index.
 Iterating through an array has good locality of
reference, and so is much faster than iterating
through a linked list of the same size, which
tends to jump around in memory.
ADVANTAGES OF ARRAYS
Compact data structures; storing 100 integers
in an array takes only 100 times the space
required to store an integer, takes no additional
storage space.
Arrays simplify algorithms by compressing
repetitive iterations, as they perform
computations on collections of data with
common attribute.
DISADVANTAGES OF ARRAYS
It has a single fixed size
Therefore, there are some indexes which refer
to invalid elements, e.g., the index 17 in an
array of size 5.
This brings range error, since it is difficult to
allow a subscript to reach a value outside its
declared range, as this will make a compiler to
generate an error.
DISADVANTAGES OF ARRAYS
Multidimensional arrays cannot be accessed by
simple indexing & these incur additional
overheads in programming its access.
For a large number of programming languages,
except for Java, the array sizes must be known
at compile time, since once space is allocated it
cannot be extended, as there is no guarantee
that the next block of memory will be free at
some time later in the execution making arrays
static data structures.
REFERENCES
Encyclopedia of Computer Science (3rd
Ed) (1993) Edited
by Ralston, A and Reilly E. D. London: Chapman and Hall
French, C. S. (1996) Computer Science. 5th
ed. London:
Book Power
Megson, G.M. (1992) An Introduction to Systolic Algorithm
Design. Oxford: Clarendon
Salmon, W. I. (1991) Structures and Abstractions: An
introduction to Computer Science with Pascal. Boston.
Irwin Inc.
Society Schools Committee (1998) A glossary of
Computing terms (9th
ed.) England: Longman
Williams, P.M. (2004) Data Structures. Sussex: University
of Sussex Computer Science and Artificial Intelligence.
http:/developer.sun.com
www.answers.com/topic/arrays

Contenu connexe

Tendances

Tendances (20)

File organization
File organizationFile organization
File organization
 
linked list
linked list linked list
linked list
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Advanced Sorting Algorithms
Advanced Sorting AlgorithmsAdvanced Sorting Algorithms
Advanced Sorting Algorithms
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting Algorithms
 
Linked lists
Linked listsLinked lists
Linked lists
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Arrays
ArraysArrays
Arrays
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 

En vedette

Lecture 2 data structures & algorithms - sorting techniques
Lecture 2  data structures & algorithms - sorting techniquesLecture 2  data structures & algorithms - sorting techniques
Lecture 2 data structures & algorithms - sorting techniques
Dharmendra Prasad
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
9781111530532 ppt ch14
9781111530532 ppt ch149781111530532 ppt ch14
9781111530532 ppt ch14
Terry Yoast
 
AWS Innovate: AWS Container Management using Amazon EC2 Container Service an...
AWS Innovate:  AWS Container Management using Amazon EC2 Container Service an...AWS Innovate:  AWS Container Management using Amazon EC2 Container Service an...
AWS Innovate: AWS Container Management using Amazon EC2 Container Service an...
Amazon Web Services Korea
 

En vedette (20)

Lecture 2 data structures & algorithms - sorting techniques
Lecture 2  data structures & algorithms - sorting techniquesLecture 2  data structures & algorithms - sorting techniques
Lecture 2 data structures & algorithms - sorting techniques
 
Data Structures- Part9 trees simplified
Data Structures- Part9 trees simplifiedData Structures- Part9 trees simplified
Data Structures- Part9 trees simplified
 
Data Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queuesData Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queues
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Data Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsData Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithms
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
 
Lecture 2c stacks
Lecture 2c stacksLecture 2c stacks
Lecture 2c stacks
 
Chap01
Chap01Chap01
Chap01
 
9781285852744 ppt ch16
9781285852744 ppt ch169781285852744 ppt ch16
9781285852744 ppt ch16
 
9781111530532 ppt ch14
9781111530532 ppt ch149781111530532 ppt ch14
9781111530532 ppt ch14
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
AWS Innovate: AWS Container Management using Amazon EC2 Container Service an...
AWS Innovate:  AWS Container Management using Amazon EC2 Container Service an...AWS Innovate:  AWS Container Management using Amazon EC2 Container Service an...
AWS Innovate: AWS Container Management using Amazon EC2 Container Service an...
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Applying Design Patterns in Practice
Applying Design Patterns in PracticeApplying Design Patterns in Practice
Applying Design Patterns in Practice
 
AWS ECS Quick Introduction
AWS ECS Quick IntroductionAWS ECS Quick Introduction
AWS ECS Quick Introduction
 
Web Database
Web DatabaseWeb Database
Web Database
 
10 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 810 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 8
 

Similaire à Lecture 2a arrays

Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
dplunkett
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 

Similaire à Lecture 2a arrays (20)

DSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notesDSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notes
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Arrays
ArraysArrays
Arrays
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Java arrays (1)
Java arrays (1)Java arrays (1)
Java arrays (1)
 
Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Arrays
ArraysArrays
Arrays
 
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
 

Lecture 2a arrays

  • 1. LECTURE 2: DATA STRUCTURES An array is a data structure consisting of a group of elements that are accessed by indexing. An array is a situation where a set of data items are conveniently arranged into a sequence & referred to by a single identifier.  Each data item of an array is known as an element & the elements are referenced by a common name known as the array name An array is a collection of objects of the same data type, allocated contiguously in memory. Individual objects in an array, called elements, are accessed by their position in the array.
  • 2. AN ARRAY The position is given by an index, which is also called a subscript. An array facilitates the coding of repetitive tasks by allowing the statements executed on each element to be put into a loop that iterates through each element in the array. An array, also known as a vector or list (for one-dimensional arrays) or a matrix (for two- dimensional arrays)
  • 3. ARRAYS An Array is a variable. It can hold a series of values, essentially, a list of values. An array provides the logical convenience of being able to reference all its values by using the single array name. As a variable, an array is an area in memory, random access memory (RAM) reserved under a name, and referred to by name, into which values can be assigned.
  • 4. ARRAYS An array is a structure that holds multiple values of the same type.  An array - known as a vector or list (for one- dimensional arrays) or a matrix (for two- dimensional arrays) It is one of the simplest data structures.
  • 5. Examples E.g. Cartoons = (Popeye, Scooby Doo, Tom & Jerry) Data Structures = (Stacks, Queues, List) Individual data items are referred to by stating their position e.g. Cartoons [1] is Popeye An array is a structure containing one or more subdivisions each of which may contain data
  • 6. TYPES OF ARRAYS One Dimensional Array Two Dimensional Array
  • 7. a) One Dimensional Array Within the array, subscripts are used to indicate the individual elements, written as integers within square brackets. 195.00 491.82 299.95 320.00 Thus credit [1] would be the first deposit in the checking account; credit [2] would be the second deposit and so on.
  • 10. One Dimensional Array The above diagrams shows a credit and Debit Array in which Credit [1] = 195.00, Credit [2] = 491.82 Credit [3] = 299.95 Similarly, Debit [1] =14.79, Debit [2] =52.25, Debit [3] =16.13, Debit [4] =44.75, Debit [5] = 114.21
  • 11. One Dimensional Array They have a single subscript and are called one-dimensional arrays; often thought of as lists. In mathematics such arrays are often called vectors. A one dimensional array is therefore an array having only one subscript & the individual elements are of the same type.
  • 12. EXAMPLE 2 To store the salaries of up to 50 employees in a firm we can use an array called salary in which salary [1], salary [2] … salary [50] are real variables that will store the salaries of the first employee, the second employee…up to the 50th employee. The array contains real elements and the subscripts run over the integer sub range [1………50].
  • 13. b) Two Dimensional Array A two dimensional array is a generalization of a linear list, for example an m x n matrix. The rows and column list essentially account for two dimensional structure of a matrix. An array contains a sequence of elements all of the same element type.  The element type can be any type, even an array (but not the same array), thus we have an array of arrays
  • 14. EXAMPLE c0 c1 c2 c3 r0 0 1 2 3 r1 1 2 3 4 r2 2 3 4 5 r3 3 4 5 6 r4 4 5 6 7
  • 15. EXAMPLE Here, we have an array with five rows and four columns.  It has twenty total elements.  However we say it has dimension five by four, not dimension twenty
  • 16. EXAMPLE We have a pay array containing 50 rows with 26 real elements on each row. Each row represents an employee and each column a pay period i.e. ( a two – dimensional array ). Pay [1,1]Pay [1,2] Pay [1,3] ……Pay [1, 26] Pay [2,1]Pay [2,2] Pay [2,3] ……Pay [2, 26] Pay [3,1]Pay [3,2] Pay [3,3] ……Pay [3, 26] : : : : : Pay [50,1]Pay [50,2] Pay[50,3]……………………… Pay [50,26]
  • 17. c) Parallel Arrays As an application of one dimensional array, we begin the construction of a payroll program to read and display employees’ salaries for a small business e.g. Enter employees’ ID numbers and salaries Employee # 1 ID Number: 11111 Salary: 222.22
  • 18. Contd...  Employee # 2 ID Number: 11112 Salary: 333.33  Employee # 3 ID Number: 11113 Salary: 444.44 Etc.
  • 19. Example The program will need to store a two – part record for each employee, containing both the integer employee number & ID– number salary. An employee record is therefore heterogeneous & cannot be stored entirely in one array. Instead we will use a pair of arrays, ID & salary which are said to be parallel arrays, because their subscripts track together: i.e. salary [I] & ID [I] together make up the data record for the 1st employee.
  • 20. Example Salary [1] Salary [2] Salary [3]
  • 21. Example ID [1] Salary [2] Salary [3]
  • 22. Question Class, What are the Components of an Array???
  • 23. COMPONENTS OF AN ARRAY An array consists of elements, data type, subscript & the square brackets. Arrays hold a series of data elements, usually of the same size & data type. The series could be of data types such as integers, strings or even floats.
  • 24. COMPONENTS OF AN ARRAY Individual elements are accessed by their position in the array. The position is given by an index, which is also called a subscript. The index usually uses a consecutive range of integers
  • 25. CHARACTERISTICS OF ARRAYS Homogeneous: They store one type of data elements. Cartesian: Arrays allow their access through an index. This referencing is possible because arrays have subscripts and elements that enable access via index
  • 26. CHARACTERISTICS OF ARRAYS Subscripts: In Pascal the subscripts are written as integers within square brackets thus credit [1] would be the first deposit in the checking account, credit [2] would be the second deposit and so on. Example [1] = 195.00 and credit [2] = 491.82 Similarly, Debit [1] = 14.79, debit [2] = 52.25 Credit array 195.00 491.82 299.95 320.27 Debit array 14.79 52.25 16.13 44.75
  • 27. CHARACTERISTICS OF ARRAYS We use subscripts to access the individual elements i.e. in a one-dimensional array, it has only one subscript & is imagined as a list or vector. The elements are stored in sequence in memory beginning with the address of the lowest-subscripted element.  A two dimensional array has two subscripts & is imagined as a table with rows & columns.
  • 28. Form the basis for several more complex data structures, e.g. hash tables, stacks and queues. Arrays provide a very special way of sorting or organising data in a computers memory Arrays serves as parameters in computation Arrays help reduce length of algorithm FUNCTIONS OF ARRAYS
  • 29. OPERATIONS ON ARRAYS Creating an array: The create function produces a new, empty array of the appropriate size.  Assigning the array: Once an array has been created a value from a field or variable, is then assigned to an element of the array. The syntax used is: Array name {element number}:= value. Array elements are numbered by their position in the array, starting at one and going up. Additionally, every array has zero element number.
  • 30. OPERATIONS ON ARRAYS Retrieving : Retrieve operation accepts an array and an index. This returns the value associated if the index is valid, or error if the index is invalid. Searching : Searching methods are designed to take advantage of the organization of information & thereby reduce the amount of effort to either locate a particular item or to establish that it is not present in a data set.
  • 31. OPERATIONS ON ARRAYS Sorting and Merging: Sorting & merging provide us with a means of organizing information to facilitate the retrieval of specific data. Field or variable: = array name {element number}
  • 32. OPERATIONS ON ARRAYS Displaying arrays: To display the contents of array on a form, you simply give an active object capable of displaying an array The contents of the array will then automatically be displayed in that object. The objects that can display the contents of an array are: Pop-up Lists/Drop-down Lists, and Combo Boxes. AN EXAMPLE????
  • 34. ADVANTAGES OF ARRAYS Arrays permit efficient random access in constant time making them most appropriate for storing a fixed amount of data which will be accessed in an unpredictable fashion.  This means that the time taken to access a[i] is the same for each index.  Iterating through an array has good locality of reference, and so is much faster than iterating through a linked list of the same size, which tends to jump around in memory.
  • 35. ADVANTAGES OF ARRAYS Compact data structures; storing 100 integers in an array takes only 100 times the space required to store an integer, takes no additional storage space. Arrays simplify algorithms by compressing repetitive iterations, as they perform computations on collections of data with common attribute.
  • 36. DISADVANTAGES OF ARRAYS It has a single fixed size Therefore, there are some indexes which refer to invalid elements, e.g., the index 17 in an array of size 5. This brings range error, since it is difficult to allow a subscript to reach a value outside its declared range, as this will make a compiler to generate an error.
  • 37. DISADVANTAGES OF ARRAYS Multidimensional arrays cannot be accessed by simple indexing & these incur additional overheads in programming its access. For a large number of programming languages, except for Java, the array sizes must be known at compile time, since once space is allocated it cannot be extended, as there is no guarantee that the next block of memory will be free at some time later in the execution making arrays static data structures.
  • 38. REFERENCES Encyclopedia of Computer Science (3rd Ed) (1993) Edited by Ralston, A and Reilly E. D. London: Chapman and Hall French, C. S. (1996) Computer Science. 5th ed. London: Book Power Megson, G.M. (1992) An Introduction to Systolic Algorithm Design. Oxford: Clarendon Salmon, W. I. (1991) Structures and Abstractions: An introduction to Computer Science with Pascal. Boston. Irwin Inc. Society Schools Committee (1998) A glossary of Computing terms (9th ed.) England: Longman Williams, P.M. (2004) Data Structures. Sussex: University of Sussex Computer Science and Artificial Intelligence. http:/developer.sun.com www.answers.com/topic/arrays