0 ratings0% found this document useful (0 votes) 28 views6 pages(DSA) Array String
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
—_——_+—__ UNIT -2Linean Date structime __—_——,
ALY,
An array is a date Steiucsuye that store conection
ide
Ob Same type stored at ContHquous memeor
g yf
locaton and Con be accessed cog an index
um [03 umes aie.
{pumice | nums7
int nurqisy; [ 3 8 =
6,0
T
Element 4. Element 3 Element =
Element 2 Element +
array 1s used +0 call a boy or
= person who is at
How to deciea7| Op affay in ©
int myarray CsJ;
‘In Gis eas aah €
array ts undefined o|
is deciasjed, neHowey
we o
ment
12,3. 47s)
nt myarray C
moke the third element to -L
vorue ob the
+myarray [2] = 1;
make ne
| «myarreytej-0
varwe bipwy element to 0
Array hove several odvantage :—
“Eppicient Storage ond wetrivel :~ array store
erement in con ep on neetl ani enren
mare it 6 ciertive erement using inere
sty Jorge ebbicient with sooge
data
vidual element using ect
vanicn mean shar aceessing any erement op array
Hime
| sane some amount
+Easy to Sort ond searteni- Array can be eais
binasty searien,
ed and
seanicned using aigoriinms like
Rg aigerithea
Which cam be mere ebpicient
nia
Array can be Used fo Fequese
y 4
ye
] nceror
| stack, queues e+e)
Array a1s0 have Some disadvantage
‘Fixed siz€i- In most programming tonguage
array naye pixed Size that Cannot bechange
once they axe Created. this can make difbicu
Jo Work With dar stHiuctu1e that need
fo grow OF Shrink, dynemicary [Ipratay Fragmen
sation)
*No built Support por inseytion or deletion:
+ Homagenous clement :~ Array can oniy
store element of ine some type Which
can be limiting por many olequirment -
*Poor Pexibormance por seme cheater.
Application of Arrays +
ment i- Array enable efbicient
Je items Of the same type
ize is know begerenand -
sMemary ma
storage ob
especiany when
+ Data Representation :— used por vector and
maFhuce In matmmatical operaHons like
mateus. mul plication»
+atabase. mangament :- Array store and
manage datasets in relations database
anowing epbisient quetying ond update.
‘Implementing Data sHructeje :— Array aye
poundaHonay por Stiuctwie like heap, has
table, and stung
“Caching 4 Buphiting :- Array act a3 bubbey
in Syste’, storing data temporarily before
LiriHing to sow] medium of Hasmitting over
ieee mei 2The F
d by
The ba
ray ¢ “
anowing
e ida
programm
ble ob
access and
Wiitn the neip
e array is bixed
sized orroy
dex
index of
usuaty
N-based
ex vote
Jaton
SUNY using ie
+ Vector
imensional
© Dimensional Array: [mi
Ob the vas jhe some
type
also a S vlandor acess and all efement
con be accessed With the neip ob thei} index
1 also be seen as a co
ection of 2>
| array 9180 Know 95 moto
+ I's dimension con pe increased pom 2 40 3
and 4 so on
{they ane viepetsjed as a
muti- dimensional array }
Row o texte | ce1g7 | xcany
Row 4 xt) to) xC00 | 07
Row 2 (129009 | x09 | xeIGI
Dynomic Array
A dynamic array. qiso know as resziqble array
'5 an arroy wnose size con be changed dining
Puntime » unlike 4¥aditiona! arrays dhe size
ob dynamic array con be increased or decresed
Qs Per the program, vtequii ment.Array Operations
gah UY POE eee
*Travensali- Visit each Element of an
array ina specifi€d ordey (eg. Sequental, reves
+ InsexHon i- Addi a New element +o an array
Ot specific. ai index.
ee a eee an Element prom an
array ot @ Specific index.
* SeanChi “fain sins the index Of AN element
in an array.
Time and space Complexity of array Operation
7
Ee ASCs sale an Element by inde
+ Time complexity: OC!)
* SPACE comptexity : o(1)
-Accessi an Element gin on
array by it's index is typicany o
operation because it directty comp
location Of the Element.
2. Insert an Element G+ ste
ea icges Corn plexity | °C) ae) hae
“Space compiexity Ot)
psa an Element at
dimensional array ust i
ane wutoy's size and py
inthe NeXt aviiaple posite
tinge opetaHon on oN eT oFNom pierity The Spoce Bona
Mow 40 deciea] sting
int maincy
i
|
3. ihse o - oF the Beginning
“Ti omptexity On) siting vie considetd a data type in genral
+ Space Complexity : o(n) ond aie Nbicany stepresent as array ob byte
: ) Element a+ ane beginning (or words) that store a sequence off Chatacts}
sinning srg as tevin may ob chee
ob a 7 array viequine Shippin
: gee ae the Bipptence bit a cnasiacre} array ond
| HA TO a Sting isthe FeIminated witn special chasjacto|
e and Space Comptenity cael
1 fn Stri
4. Sea ter on Etement (tineaxy Element) 3G.
| Time compiexity : O(n) Chor Stoi 0] = "Greews™
+ space eu) 4
+ In he SE. Searching por on indee—> , , aan
te ond. 1 3g sr — [alee «EY
: ne -dimensional array may oss a
DIE looking at every Element, res Oa
Mdeciex| and
ent still -
exity 20
omplexity 001)
In the Worst case » Sesctentm—per_an
Etement deieting an Element pom “ane pont
Loy tore Otn) +
ted
ee
renin 0;
Ne OS Element opto} an Element:
by ane Position JString Manupuig tion
Se MANIPUIaAHON basicany nNebeis to
the process Of handii and anatyzi
es
HF involve Voulious opeslation conceyned
oF Sing
's date. okbet a
built punction +o manipulate.
if Contents ob ree
With modification and pouisi
Oo USE eric eninge
selies of In-