0% found this document useful (0 votes)
38 views18 pages

Data Structure

The document discusses array data structures and common operations that can be performed on arrays. It defines what an array is, how they are represented in memory, and basic array operations like accessing, modifying, traversing, searching, merging and splitting elements. It also covers advantages and disadvantages of arrays and provides examples of array declarations and programs.

Uploaded by

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

Data Structure

The document discusses array data structures and common operations that can be performed on arrays. It defines what an array is, how they are represented in memory, and basic array operations like accessing, modifying, traversing, searching, merging and splitting elements. It also covers advantages and disadvantages of arrays and provides examples of array declarations and programs.

Uploaded by

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

DATA

STRUCTURES
-SWATHI R (BCA IST YEAR ‘A’)
ARRAY
OPERATIONS
Here is where my presentation begins
INTRODUCTION
● An array is a fundamental data structure that is
widely used in computer science and programming.

● It is a collection of elements of the same type,


organized in a contiguous block of memory.

● Array operations are the various ways in which we


can manipulate and access the elements of an array.
SOME COMMON ARRAY OPERATIONS:

• Accessing elements
• Modifying elements
• Traversing elements
• Searching for a elements
• Merging two arrays
• Splitting an arrays
WHY DO WE NEED ARRAY OPERATIONS?
● Efficient storage and retrieval of data: Arrays provide a
convenient way to store a collection of elements of the same type in
contiguous memory locations. By using array operations, we can
efficiently access and manipulate the elements of an array.
● Data analysis: In many applications, we need to analyze and
manipulate large datasets. Arrays provide an efficient way to store
and access this data, and array operations allow us to process it in
various ways.
● Algorithm design: Many algorithms involve manipulating arrays.
For example, sorting algorithms, searching algorithms, and graph
algorithms often require array operations to work efficiently.
● Software development: Arrays are used extensively in software
development, from simple applications to complex systems. By
understanding array operations, developers can write more efficient
and effective code.
.
DEFINITION OF CONCEPTS

The numerous operations or activities that may be


carried out on an array are referred to as "array
operations" in data structures.
A data structure known as an array holds a group of
identically data-typed elements in a contiguous block
of memory.
We can alter and access an array's elements in a
number of different ways thanks to array operations .
Representation of an array
We can represent an array in various ways in different
programming languages. As an illustration, let's see the
declaration of array in C language -
WHY ARE ARRAYS REQUIRED?
Arrays are useful because -
• Sorting and searching a value in an array is easier.
• Arrays are best to process multiple values quickly and easily.
• Arrays are good for storing multiple values in a single variable - In
computer programming, most cases require storing a large number of data of
a similar type. To store such an amount of data, we need to define a large
number of variables. It would be very difficult to remember the names of all
the variables while writing the programs. Instead of naming all the variables
with a different name, it is better to define an array and store all the elements
into it.
MEMORY ALLOCATION OF AN ARRAY
HOW TO ACCESS AN ELEMENT FROM THE
ARRAY?
Byte address of element A[i] = base address + size * ( i - first index
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
bytes, float takes 4 bytes of memory space in C programming.
• We can understand it with the help of an example -
Suppose an array, A[-10 ..... +2 ] having Base address (BA) = 999 and size of an element = 2 bytes, find
the location of A[-1].
L(A[-1]) = 999 + 2 x [(-1) - (-10)]
= 999 + 18
= 1017
BASIC OPERATIONS
Now, let's discuss the basic operations supported in the array –
Traversal - This operation is used to print the elements of the array.
Insertion - It is used to add an element at a particular index.
Deletion - It 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.
Update - It updates an element at a particular index
ADVANTAGES OF ARRAY

• Array provides the single name for the group of variables


of the same type. Therefore, it is easy to remember the
name of all the elements of an array.
• Traversing an array is a very simple process; we just
need to increment the base address of the array in order
to visit each element one by one.
• Any element in the array can be directly accessed by
using the index.
DISADVANTAGES OF ARRAY

• Array is homogenous. It means that the elements


with similar data type can be stored in it.
• In array, there is static memory allocation that is
size of an array cannot be altered.
• There will be wastage of memory if we store less
number of elements than the declared size.
2D ARRAY
• 2D array can be defined as an array of arrays. The 2D array is
organized as matrices which can be represented as the collection of
rows and columns.
• However, 2D arrays are created to implement a relational database
look alike data structure. It provides ease of holding bulk of data at
once which can be passed to any number of functions wherever
required.
HOW TO DECLARE 2D ARRAY

int arr[max_rows][max_columns];
EXAMPLE 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]);
}
}
OUTPUT

Element of the array are:


Arr[0]=18 Arr[1]=30 Arr[2]=15 Arr[3]=70 Arr[4]=12
THANKS!

CREDITS: This presentation template was created by


Slidesgo, incluiding icons by Flaticon, and
infographics & images by Freepik.

You might also like