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

operationsvin a linear array

The document discusses algorithms for traversing, inserting, and deleting elements in a linear array. It outlines the steps for insertion and deletion operations, providing pseudocode examples for clarity. Additionally, it emphasizes the importance of understanding these algorithms for effective array manipulation.

Uploaded by

helper bisht
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)
12 views

operationsvin a linear array

The document discusses algorithms for traversing, inserting, and deleting elements in a linear array. It outlines the steps for insertion and deletion operations, providing pseudocode examples for clarity. Additionally, it emphasizes the importance of understanding these algorithms for effective array manipulation.

Uploaded by

helper bisht
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/ 6

Fperalions a dines Ara

a ina Array

Teutsiny lina
or acces ach elenenl o a tinca
y meQnd

aay
to

Traver sal olisplays all the elimenls of the artay


LA’ ineor Ariay
LB’dower Bound
U8’ uppu Bound
Higoxithna or tiavusirg the ineo
Jotialize the counle j set i:: L6 .
3 au 4 whie i c VB.
3.
ViitJrvemént
evvy
tvey elament i. e PaccESs LA].
counlek ie l:= i+1
exT.

OR
1
PeocESS o AJi].
EXIT.
Jrsertion and eleton in ina Akkau
nenting vqus to he peaton ¢ addiy oneher
element to the cay and deletingthe refls to
elem enls
the ojerationn eñovig
one

ron the arlay

Alqoithmn oe insetion in dineak ARAY


IN SERT (LA, N, K,Item) (N
whue LA i o inear aray with, elemenls
and K js a pos' tive inleg Buch that K<N.

The alyonithn will inset IYem into he Kkh position


Jitialize counle ie del : N-I
Repuat sleps 3and 4whilejK bositan
Move the tth lnent to he next þaition
set LALjH]:- LAI[]
deer ase counte ije
Jnsent He elment at the reguird pacitin
det LA[K:: Ilem
N
Reset N ie f a t uncsement
by I .
fok underslanding the algorilhm
ol
ExampBe
auume We have Jhe
del
Jineor oroy
|5
3
2

Total no of elemens ane 5.


N elilrs
Sine indexing slaste tom O..
ikdex pasiton
JE N
áset element at 3rd poition
Now it we
value ot k:
true
(l) No K
element at jh positon to (i+i)4
Tionsfer the Element 5 s tvansfeed.
þoshon Hence Elerent 5
to te 5th locatian ef ae array
ij-! ie f- 4-)- 3
Noo-!
for j*3 ie j>k 32
(i) Aqain Yepat chifed wpoauda aud
deeremeuled o
Now aud
(V)
Cordihion is tue Elent 3 e
shitred upwNd1 aud ju o w 1
Condition bicou
No) ,
w)

iu terminaled ii
grd bosthcn
execuled i e
Now Sip5 is
(V)
ie cAlk]= Ilem
LA2]: T•en
elemen's is
Nhd 0 of aray
(VN) inserle
eliment

(ix)
for deletion in lineau Areay
(L4, N, K, Item) Nelimenls
JELETE wit
ineo crray deleles
where iniegerl The
iu a positiv
ad K LA

LAlK]
1 Set Jtemi: w-)
j:k to
2 Kpeat fol positien brckd
lement one
mo each
Bet LA: LAlJ) element
N
Nto ne
ele menls
3 Resel
total no
elemens
Jess Hon the
WAP to weale a linea
o/au uexe
whese no leens
Qxe enlered by the we
ad alao
elemens enloed
include <stliol Headee fle sondad
wsid for inpul and aulput
oheralois i e pinti aud
seang
qeloá () noion i.e ueed to
ouput s creen

void main() / ExeCbion tf any pgram Alaua from


yoid main/ )
Sze l80 elmens
ist a lo]:
|/ eclaing vai ables
Screln

ceser O; sd fok dearing the Guput

"enle no elemnsn).
the use
seanf ("fed ); 70 enler elemenls
for(i=0, icn: i+) in the avray from
frnt ("Enlen clement the cse
the elenols
fintt ( 'Elemenls are
in the
glch C): array

You might also like