Shubham Upadhyay
DATE
ARRAY PAGE
An asay is q data structuxe that stores
a tixed- Size sequehce of elements of the
Same type. Hexe axe some key points about
azays:
Chaxactexistics
1- Fixed Size:
The size of an axray is deined at the time
of czeation and cannot be changed.
2- Homcogeneous Elements:
AII elements in qn arzay are of the same
data type (e-g., integers, floats, Staings).
3 Contiquous
ContiOUS Memoxy:
Elements ave stoxed in contiguous memory
locations, allowing fox efficent access.
Types of Arzays
1- One-Dimensional Axays A lineas list of
elements.
Example: int qxsL51-{1,2,3,4,5};
Shubham Upadhyay
DATE.
PAGE
2.. Multi-Dimension al Arzays:
Azxays of axzays, commonly used fox matzices:
Example: int matzix [31[3]= {1,2,33,{4,5, 63,
{, 8, 93;
Common Opexationsi
Access: Retrieve an element using its index.
Ceg,aCo1).
Insestion: Add elerments (usually zequives
shifting).
Deletion: Remove elements (also requives shifing
Tyaversal: Loop thxough all elements.
Pxos Qnd Cons
Pros:
Fast access time (O(1) for indexing).
Simple to implement.
Cons:
|Fixed size can lead to wasted space ox overflow.
Insestion deletionCon be castly(0Cn).
Shubham Upadhyay
DATE
PAGE
Use Coases :
Stosing collections of data Clike lists of
numbes).
Implementing other data structures Clike
stacks , queves, and matzices).