Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DS ASSIGNMEM1-2

Q1]Eplain di{ferent tynesof dato structures.


Dota Structure!
Linedr Non- Lineac

P Arays H TreeS.
Linked list +Granh
Stack
Queue

)Linear Data Structure &


il| Tn Lineor dota shucturedata elements ar
arranged in a linear order.
21| Single evelis involved.
3Dato tem cqn be trayersed in asingle run.
Eass to implement in the computers memory.
5]. Menory is not utilized in an eficient ay.
6E Array-, liaked list Stack,Queue.
H PushITon Front Rear
-Tor

orray stack QUeue

Línk List
2) Non- Lînear Dato Sbyucture :
4 In Non- Linear data structure, data elements_are
attachedin hierarchicalymanhêr
2l| WhereOS 0n non-linear ata styucture, mulbiale levels
are involved.
3Dato iterns Can not be traversed ín a single
These aye dificult to implement
5 Memory ís ulized in an
6]Er Tree, Crranh effitient ay
)Prímitive Data structure
It
de fines a set of nnitire elerments uhich do
not involve any other elements as its Subnarts.
4)Non-Primi tie Data structure
1 IE defines a set ot deried elements such
as array. Aray dato struckure defined
consist ö4 a set of similar tyne'of elements.
Static Datq Struture i
A1In static data structare the size of the structure
e content o# O the dota structure can be
madiffed
modiie uthguoithout
Snace allowedto it. changing the memoy
eg. acray
6 Dynamic data structure
Tn dynomic stncture the size af the stucurt is
not fked and cay be rnodified during the
Page

lloneratons nerformed on Pt
datd structures are desined to faci iitat
punomic
Dynanic in t h un time
echonge of data struckure

02Exlain memory allocakion eunctions în detail.


Memory Allocation.
Pointer Dyaamic
Pointers
A nointec in cis Used to allocate memory dyn
mcallyi:e at run tine
stares thevalue shereas
1Norma variale stoves the addvess at the
poipter wariable
Voiable
The ontent ofthe cnointer alays is a
le number iee. int*
u Alwaus Cnointer is initolized to nall
nat
Symbol is used to get the addrss the
Varole . eg int oz 50;
Dynamicz memoryatruntime
1 h enocess o allocathng
is Knowh as Dynamic lemonyAllocation.
this facilitg
inherenty haueknocn
Ahough Cdoea notibrony
four rautnes es "memo
ther are can he ased for
that
ions memory during nri an
aocatoo
alo catnq and eRe ing
Cxecutions.
Page

Q.al Mlyot ic pointen? ecploin uith examnle, i


ahon and acessing.
Pointer i
1A nainter in Ci used to alocate memory dyna
Ily i-eat, nun time.
Nomal variakle storts the add rrs of the valy
ohereos
Vanasle.
painter variable storer the addreg ap
3he ontent of the cnointer always is a who
nonben e addrtss.
incude <stdio.h>

int a50:
ntr
nrint \n value o az"d, a;
ntn
Anhtfr
valute of_ntre'd
hnh("In valye of ntr 'd,k ntc);

QExolain
ynedef typede; keyword cath an ezann nle
keycJord
ipvedefnedkeqword
eristin Vàroudn give a meanin
gf,name to on n yourChrograM
31 Ta implerment th ynedef keyuord aucessf ullg
wil imnlcmentae a naone to an ecistng data
+you
hae to
tyne in the program code. cato
) Then the
ith the Compiler
name yhat
replace
hat you haue
the eisting data tyne
entire nlcat on. nrov1ded for he
# incbade, <staig. he
tynedef int aint; l de lared o new vanable of int
data tyne!
int mauh()
print ("1ech vidvan Tutoviol; ExomFle of tyne def keya
ord InIn);
int a = 0;
ain1b50, (;
atb; isi-d")
print ("Sam
retun.0;

QS] Whatis algonthm? what_ are he characterishcs of


an. alqrt
’ An olgonthm is Qa finiteseqence of instuctons,
each of uhlchas a clean meaning and can
be exe cuted cuth
in finite tme.
a finite amount of effort
chaa ctestics
1 Innut An algoithm should accent Zeroor mor
innuts
1 Output’ An algorithm ust produce atleast one
resall
3 Definiteness’ Each ster is an. dlgorithm and must
beceatand unambiquous
4 Fni teness ’ An glqorithin must malt, Henct must
teçnirate aften a fnite nunaber of
stens..
sl ttectireneS ’’ Each inctructon must be done in finit
s].
time by a person using only paner and pencil
Qs what is time complexity? exnlain in detail.
Time com plexily
f Eveny alqorithm ques some amount o comaute
tin toexecute is inçtructhon to nerjorm he toc
This comnuter tme raured is called Hmt (omnl
ity
1neinaion'- "The tine complexity o an algorithn
the total amoantb tme qntd by an
to çomalete ik 'xecatioa alge
me equred by each stakement denends on:
Time rqued
xeting ttonCe
ii) Nambero times the statement is
UJ Tynes of time conlexit executed
Bt case ii) 6rst cas i1) Auernge (ase.

+incude <stdio.h
# incudeestdlib.h
VDId main C)

int array liol


int i, nm, expj
aler the orden of he
icanf "d" &nun): palyhomial ln'
nrinEhter
`Canlo{"
the valse of n
rifEnten tod coefficieals
fur (i=0, 1nun, iit) n", num ti
s.an"d"&artay Ci]);

CspnunM
print ( Griven nolynomial is ln"
tr izo;i<-hum itt)

iGatraycr]20)
etef else (aayci<0)
pint
el_e
nnntfdx^dahs
nclnfIn Sunn ef he nalynomial= af nps

You might also like