0% found this document useful (0 votes)
59 views5 pages

Array

An array is a collection of items of the same type stored in contiguous memory locations that can be indexed. It is commonly used to represent multiple instances of data through a single variable name. There are different types of arrays including one-dimensional arrays which can be thought of as a row of elements, and two-dimensional arrays which can represent a matrix with rows and columns. Arrays allow for fast random access to elements but have fixed sizes, making insertion and deletion difficult. They are commonly used to implement other data structures and for sorting algorithms.

Uploaded by

Game Zone
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)
59 views5 pages

Array

An array is a collection of items of the same type stored in contiguous memory locations that can be indexed. It is commonly used to represent multiple instances of data through a single variable name. There are different types of arrays including one-dimensional arrays which can be thought of as a row of elements, and two-dimensional arrays which can represent a matrix with rows and columns. Arrays allow for fast random access to elements but have fixed sizes, making insertion and deletion difficult. They are commonly used to implement other data structures and for sorting algorithms.

Uploaded by

Game Zone
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/ 5

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..

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.

Representation of Array
Why Array Data Structures is needed?
Assume there is a class of five students and if we have to keep records of their
marks in examination then, we can do this by declaring five variables individual
and keeping track of records but what if the number of students becomes very
large, it would be challenging to manipulate and maintain the data.
What it means is that, we can use normal variables (v1, v2, v3, ..) when we have a
small number of objects. But if we want to store a large number of instances, it
becomes difficult to manage them with normal variables. The idea of an array is
to represent many instances in one variable..
Types of arrays:
There
here are majorly two types of arrays:
 One-dimensional
dimensional array (1(1-D arrays): You can imagine a 1d array as a row,
where elements are stored one after another.

1D array

 Two-dimensional
dimensional array: 2-D Multidimensional arrays can be considered as an
array of arrays or as a matrix consisting of rows and columns.

2D array

 Three-dimensional
dimensional array: A 3-D Multidimensional array contains three
dimensions,
ensions, so it can be considered an array of two
two-dimensional
dimensional arrays.
3D array

Types of Array operations:


 Traversal: Traverse through the elements of an array.
 Insertion: Inserting a new element in an array.
 Deletion: Deleting element from the array.
 Searching: Search for an element in the array.
 Sorting: Maintaining the order of elements in the array.
Advantages of using Arrays
Arrays:
 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 it items
ems of the same type using a single name.
 Arrays store multiple data of similar types with the same name.
 Array data structures 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
increaseded 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 ca cannot
nnot 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.
Application of Array:
 They are used in the implementation of other data structures such as array lists,
heaps, hash tables, vectors, and matrices.
 Database records are usually implemented as arrays.
 It is used in lookup tables by computer.
 It is used for different sorting algorithms such as bubble sort insertion sort,
merge sort, and quick sort.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy