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

Unit 1

Uploaded by

Sai Nikhila
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)
16 views7 pages

Unit 1

Uploaded by

Sai Nikhila
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

Array Data Structure

An array data structure is a fundamental concept in computer science that


stores a collection of elements in a contiguous block of memory. It allows for
efficient access to elements using indices and is widely used in programming
for organizing and manipulating data.

Array Data Structure

What is an Array?

An array is a collection of items of the same variable type that are stored at

contiguous memory locations. It’s one of the most popular and simple data

structures and is often used to implement other data structures. Each item in

an array is indexed starting with 0 . Each element in an array is accessed

through its index.


Need of Array Data Structures

Arrays are a fundamental data structure in computer science. They are used

in a wide variety of applications, including:

● Storing data for processing

● Implementing data structures such as stacks and queues

● Representing data in tables and matrices

● Creating dynamic data structures such as linked lists and trees

Types of Array

There are two main types of arrays:

● One-dimensional arrays: These arrays store a single row of

elements.

● Multidimensional arrays: These arrays store multiple rows of

elements.

Array Operations

Common operations performed on arrays include:

● Traversal : Visiting each element of an array in a specific order (e.g.,

sequential, reverse).
● Insertion : Adding a new element to an array at a specific index.

● Deletion : Removing an element from an array at a specific index.

● Searching : Finding the index of an element in an array.

Applications of Array

Arrays are used in a wide variety of applications, including:

● Storing data for processing

● Implementing data structures such as stacks and queues

● Representing data in tables and matrices

● Creating dynamic data structures such as linked lists and trees

Basic terminologies of Array


● Array Index: In an array, elements are identified by their indexes.

Array index starts from 0.

● Array element: Elements are items stored in an array and can be

accessed by their index.

● Array Length: The length of an array is determined by the number

of elements it can contain.

Types of Arrays on the basis of Dimensions:


1. One-dimensional Array(1-D Array): You can imagine a 1d array as a row,
where elements are stored one after another.

arr[5]=arr[5]-1

2. Multi-dimensional Array: A multi-dimensional array is an array with more

than one dimension. We can use multidimensional array to store complex


data in the form of tables, etc. We can have 2-D arrays, 3-D arrays, 4-D
arrays and so on.

● Two-Dimensional Array(2-D Array or Matrix): 2-D

Multidimensional arrays can be considered as an array of arrays or

as a matrix consisting of rows and columns.


● Three-Dimensional Array(3-D Array): A 3-D Multidimensional

array contains three dimensions, so it can be considered an array of

two-dimensional arrays.
Advantages of Array
● Arrays allow random access to elements. This makes accessing

elements by position faster.

● Arrays have better cache locality which makes a pretty big

difference in performance.

● Arrays represent multiple data items of the same type using a

single name.

● Arrays are used to implement the other data structures like linked

lists, stacks, queues, trees, graphs, etc.


Disadvantages of Array
● As arrays have a fixed size, once the memory is allocated to them, it

cannot be increased or decreased, making it impossible to store

extra data if required. An array of fixed size is referred to as a static

array.

● Allocating less memory than required to an array leads to loss of

data.

● An array is homogeneous in nature so, a single array cannot store

values of different data types.

● Arrays store data in contiguous memory locations, which makes

deletion and insertion very difficult to implement. This problem is

overcome by implementing linked lists, which allow elements to be

accessed sequentially.

You might also like