0% found this document useful (0 votes)
6 views

data structures & algorithms

Data structure and algorithms
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

data structures & algorithms

Data structure and algorithms
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

data structures &algorithm

Array in
Data Structures
ObjectiveS
ARRAY:INTRODUCTION,DECLARATION ,
INITIALISATION OFARRAYS
TYPES OF ARRAYS
OPERATIONS ON ARRAYS
SEARCHING TECHNIQUES(LINEAR,BINARY SEARCH)
SORTING TECHNIQUES(BUBBLE,INSERTION,
MERGE,QUICK,SELECTION SORTS)
ADVANTAGES &DISADVANTAGES OF ARRAYS
CONCLUSION
WHAT ARE ARRAYS?
Arrays are data structures that hold a
collection of elements, typically of the
same data type, in a contiguous
memory location. Each element in an
array can be accessed using an index,
which makes it easy to retrieve and
update data.
DECLARATION OF AN ARRAY:
Arrays are declared by specifying the data type of their
elements followed by square brackets. For example,
SYNTAX:datatype array_name[arraysize];
In C:
int numbers[10];
INITIALISATION of arrays:
Arrays can be initialized at the
time of declaration or later in the
code. For example, in Java

int numbers[] = {1, 2, 3, 4, 5};


TYPES OF ARRAYS:
**One-dimensional arrays**: A
simple list of elements.
**Multi-dimensional arrays**:
Arrays of arrays, such as two-
dimensional arrays (matrices).
**Jagged arrays**: Arrays
containing arrays of different sizes.
OPERATIONS on arrays:
**Traversing**: Iterating through the array elements.
**Insertion**: Adding new elements.
**Deletion**: Removing elements.
**Searching**: Finding elements.
**Sorting**: Arranging elements in a specific order.
## Searching Techniques
Arrays can be searched using various algorithms:

**Linear Search**: Iterates through each element until


the target value is found.
**Binary Search**: More efficient for sorted arrays,
repeatedly divides the search interval in half to locate
the target value.
Sorting Techniques
Several algorithms can be used to sort arrays, each with its advantages and
disadvantages:

**Bubble Sort**: Simple but inefficient for large datasets.


**Insertion Sort**: Efficient for small arrays or nearly sorted data.
**Merge Sort**: Divides the array into subarrays, sorts them, and then merges
them.
**Quick Sort**: Employs a divide-and-conquer strategy, generally faster but
can be inefficient in the worst case.
**Selection Sort**: Repeatedly selects the smallest element and swaps it with
the first unsorted element.
disadvantages :
**Fixed size**: Once declared, the size of an
array cannot be changed.
**Memory wastage**: Unused allocated
memory can be wasted.
**Insertion and deletion**: Operations can be
inefficient as they may require shifting
elements.
CONCLUSION:
Arrays are fundamental to programming, providing a
structured way to store and manipulate data.
Understanding their types, declaration, initialization,
and operations is crucial for efficient coding and
problem-solving. While they come with both
advantages and disadvantages, their role in
simplifying data management and algorithm
implementation makes them indispensable in the
world of programming.

You might also like