0% found this document useful (0 votes)
26 views7 pages

Lecture 2

An array is a linear data structure that stores elements of the same data type in contiguous memory locations, with a fixed size and indexed access. While arrays allow easy implementation and random access, they have limitations such as fixed size and costly insertion/deletion operations. Arrays are widely used in applications like database systems, image processing, and data analysis.

Uploaded by

aleezaarshad397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views7 pages

Lecture 2

An array is a linear data structure that stores elements of the same data type in contiguous memory locations, with a fixed size and indexed access. While arrays allow easy implementation and random access, they have limitations such as fixed size and costly insertion/deletion operations. Arrays are widely used in applications like database systems, image processing, and data analysis.

Uploaded by

aleezaarshad397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction of Array

Arrays in Data Structures


Definition: An array is a linear data structure that stores
elements of the same data type in contiguous memory
locations.
Visual Representation: Use a diagram to show an array
of size 5 storing integers, e.g., [10, 20, 30, 40, 50].

2
Key Characteristics of Arrays
Fixed Size: Once an array is declared, its size cannot be changed.

Homogeneous Data: All elements in an array must be of the same


type (e.g., integers, floats).
Contiguous Memory: Elements are stored one after another in
memory.

Indexed Access: Each element has an index, starting from 0.


Example:
• Access the first element: array[0].
• Access the third element: array[2].
3
Advantages of Arrays
• Easy to implement and use.
• Allows random access to elements using indices.
• Useful for storing data when the size is known.

4
Limitations of Arrays
• Fixed size: Cannot grow or shrink dynamically.
• Insertion and deletion operations are costly (require
shifting elements).
• Stores only homogeneous data types.

5
Applications of Arrays
• Database Systems: Storing rows and columns of a
table.
• Image Processing: Representing images as 2D arrays
(pixels).
• Data Analysis: Representing datasets in tabular form.
• Mathematics: Storing matrices for linear algebra.

6
Types of Arrays
• One-Dimensional Arrays:
A single row of elements.
Example: [10, 20, 30, 40, 50].
• Multi-Dimensional Arrays:
Arrays with more than one dimension (e.g., 2D, 3D arrays).
2D Array Example (Matrix).

(0,0) (0,1) (0,2) (0,3) (0,4) (0,5)

(1,0) (1,1) (1,2) (1,3) (1,4) (1,5)

(2,0) (2,1) (2,2) (2,3) (2,4) (2,5)

You might also like