CONCEPT OF ARRAY IN DATA STRUCTURES CONCEPT OF ARRAY IN DATA STRUCTURES

MSridhar18 4 views 24 slides Feb 26, 2025
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

CONCEPT OF ARRAY IN DATA
STRUCTURES


Slide Content

CONCEPT OF ARRAY IN DATA
STRUCTURES



Ms.C.NANDHINI
Assistant Professor
Department of Information Technology
Sri Ramakrishna College of Arts and Science
Coimbatore - 641 006
Tamil Nadu, India

1

CONTENT
•INTRODUCTION
•BASIC TERMINOLOGIES
•MEMORY ALLOCATION OF AN ARRAY
•PROBLEM
•BASIC OPERATIONS

INTRODUCTION
•Arrays are collections of related types of data
items that are stored in adjacent memory
locations.
•It is one of the most basic data structures in
which each data element can be accessed at
random by using its index number.
1001 1002 1003 1004 1005
56 43 65 98 12
0 1 2 3 4
Address
Element
Index

TERMINOLOGY
•TYPE- The type of array represents the kind of
data type it is meant for. For example an array
of integers, an array of characters, strings etc.
Int i=10;
Int m=20;
Int j=50;
Int u=45;

Multiple variables
to stores same type
of data element

10
int arr[4]={10,20,50,45}

20 50 45
Single variable to store multiple
values of same type

Variable arr of size 4 follows
integer type

TERMINOLOGY
•SIZE- The number of elements in an array is
called size of array. The size is also called
length or dimension.

TERMINOLOGY
•BASE- The base of an array is the address of
the memory location where the first element
of the array is located.
453
454
455
.
.
.

TERMINOLOGY
•INDEX- All the elements of an array can be
referenced by subscript like Ai or A[i] this
subscript is known as index.
•An index is always an integer value.

Memory Allocation of an array
•In the above image, we have shown the memory allocation of an
array arr of size 5.
•The array follows a 0-based indexing approach. The base address
of the array is 100 bytes.
•It is the address of arr[0]. Here, the size of the data type used is 4
bytes; therefore, each element will take 4 bytes in the memory.

How to access an element from the
array?

•We required the information given below to access any random
element from the array -
Base Address of the array.
Size of an element in bytes.
Type of indexing, array follows.
•The formula to calculate the address to access an array element -




•Here, size represents the memory taken by the primitive data types.
As an instance, int takes 2 or 4 bytes, float takes 4 bytes of
memory space.

Byte address of element A[i] = base address + size * ( i - first index)

•We can understand it with the help of an
example -
•Suppose an array, A[0…..9] having Base
address (BA) = 104 and size of an element(s) =
2 bytes, find the location of A[3].
•Address(k) = BA+s(k-LB)
•A[3] = 104+ 2 x [3 - 0]
= 104+6
=110

Try…..

How to store value in array

Basic operations

•Traversal - This operation is used to print the
elements of the array.
•Insertion- is used to add an element at a particular
index.
•Sorting- It is used to sort an element in a specific
order(ascending/ descending)
•Deletion- is used to delete an element from a
particular index.
•Search - It is used to search an element using the
given index or by the value.

Traversal operation

•This operation is performed to traverse through the array
elements. It prints all array elements one after another. We
can understand it with the below program –
#include <stdio.h>
void main() {
int Arr[5] = {18, 30, 15, 70, 12};
int i;
printf("Elements of the array are:\n");
for(i = 0; i<5; i++) {
printf("Arr[%d] = %d, ", i, Arr[i]);
}
}

Insertion operation

Sorting operation
..

Delete operation

Search operation

Try…

THANK YOU
Tags