119
C H T I W S R E T C U R T S A T A D 5 3 S C 0 1 C F O T P E D T I B J S , E S e g a P 1 C H T I W S E R U T C U R T S A T A D ) E S I & E S C o t n o m m o C ( 5 3 S C 0 1 : e d o C t c e j b u S 5 2 : s k r a M . A . I 4 0 : k e e W / s r u o H 3 0 : s r u o H m a x E 2 5 : s r u o H l a t o T 0 0 1 : s k r a M m a x E T R A P – A T I N U - 1 s r u o H 8 : S T P E C N O C C I S A B , n o i t a c o l l A y r o m e M c i m a n y D d n a s r e t n i o P a t a D , n o i t a c i f i c e p S m h t i r o g l A t n e m e r u s a e M e c n a m r o f r e P , s i s y l a n A e c n a m r o f r e P , n o i t c a r t s b A T I N U -2 s r u o H 6 : S E R U T C U R T S d n a S Y A R R A , s n o i n U d n a s e r u t c u r t S , s y a r r A d e t a c o l l A y l l a c i m a n y D , s y a r r A l a n o i s n e m i d i t l u M f o n o i t a t n e s e r p e R , s e c i r t a M e s r a p s , s l a i m o n y l o P s y a r r A T I N U - 3 s r u o H 6 : S E U E U Q D N A S K C A T S g n i s U s e u e u Q r a l u c r i C , s e u e u Q , s y a r r A c i m a n y D g n i s U s k c a t S , s k c a t S . s e u e u Q d n a s k c a t S e l p i t l u M , s n o i s s e r p x E f o n o i t a u l a v E , s y a r r A c i m a n y D T I N U - 4 s r u o H 6 : S T S I L D E K N I L s e r p e R , s n i a h C d n a s t s i l d e k n i L y l g n i S , s e u e u Q d n a s k c a t S d e k n i L , C n i s n i a h C g n i t n e s t s i L d e k n i L y l b u o D , s e c i r t a M e s r a p S , s n o i t a r e p o t s i L l a n o i t i d d A , s l a i m o n y l o P T R A P - B T I N U - 5 s r u o H 6 S E E R T : 1 . s p a e H , s e e r T y r a n i B d e d a e r h T , s l a s r e v a r T e e r T y r a n i B , s e e r T y r a n i B , n o i t c u d o r t n I T I N U – 6 s r u o H 6 S E E R T : S H P A R G , 2 , s t e S t n i o j s i D f o n o i t a t n e s e r p e R , s t s e r o F , s e e r T n o i t c e l e S , s e e r T h c r a e S y r a n i B . e p y T a t a D t c a r t s b A h p a r G e h T , s e e r T y r a n i B g n i t n u o C T I N U - 7 s r u o H 6 S E U E U Q Y T I R O I R P e l g n i S - e l b u o D d n a - , s e e r T t s i t f e L , s e u e u Q y t i r o i r P d e d n E , s p a e H l a i m o n i B . s p a e H g n i r i a P , s p a e H i c c a n o b i F T I N U - 8 s r u o H 8 : S E E R T H C R A E S Y R A N I B T N E I C I F F E d e R , s e e r T L V A , s e e r T h c r a e S y r a n i B l a m i t p O - , s e e r T k c a l B . s e e r T y a l p S : k o o B t x e T n o s r e d n A , i n h a S , z t i w o r o H . 1 - 2 , C n i s e r u t c u r t S a t a D f o s l a t n e m a d n u F : d e e r F d n . 7 0 0 2 , s s e r P s e i t i s r e v i n U , n o i t i d E ) 0 1 , 5 . 9 o t 1 . 9 , 1 . 6 , 1 1 . 5 o t 5 . 5 , 3 . 5 o t 1 . 5 , 4 , 3 , 6 . 2 o t 1 . 2 , 1 s r e t p a h C ( : s k o o B e c n e r e f e R 2 , + + C d n a C g n i s U s e r u t c u r t S a t a D : m u a b n e n n a T , n i e t s n e g u A , h a y d i d e Y . 1 d n . 3 0 0 2 , n o i t a c u d E n o s r a e P , n o i t i d E a m a S s i s a b e D . 2 2 , s e r u t c u r t S a t a D c i s s a l C : a t n d n . 9 0 0 2 , I H P , n o i t i d E e g a g n e C , C h t i w h c a o r p p A e d o c o d u e s P A s e r u t c u r t S a t a D : n a z u o r o F . A z u o r h e B d n a g r e b l i G . F d r a h c i R . 3 . 5 0 0 2 , g n i n r a e L i t a c u d E n o s r a e P , C n i n g i s e D m a r g o r P & s e r u t c u r t S a t a D : g n u e L e c u r B & e s u r K t r e b o R . 4 . 7 0 0 2 , n o

DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 1

C HTIW SERUTCURTS ATAD )ESI & ESC ot nommoC(

53SC01 :edoC tcejbuS 52 : skraM .A.I 40 : keeW/sruoH 30 :sruoH maxE 25 : sruoH latoT 001 :skraM maxE

TRAP – A TINU - 1 sruoH 8

:STPECNOC CISAB ,noitacollA yromeM cimanyD dna sretnioP ataD ,noitacificepS mhtiroglAtnemerusaeM ecnamrofreP ,sisylanA ecnamrofreP ,noitcartsbA

TINU - 2 sruoH 6

:SERUTCURTS dna SYARRA ,snoinU dna serutcurtS ,syarrA detacollA yllacimanyD ,syarrAlanoisnemiditluM fo noitatneserpeR ,secirtaM esraps ,slaimonyloP syarrA

TINU - 3 sruoH 6

:SEUEUQ DNA SKCATS gnisU seueuQ ralucriC ,seueuQ ,syarrA cimanyD gnisU skcatS ,skcatS.seueuQ dna skcatS elpitluM ,snoisserpxE fo noitaulavE ,syarrA cimanyD

TINU - 4 sruoH 6

:STSIL DEKNIL serpeR ,sniahC dna stsil dekniL ylgniS ,seueuQ dna skcatS dekniL ,C ni sniahC gnitnestsiL dekniL ylbuoD ,secirtaM esrapS ,snoitarepo tsiL lanoitiddA ,slaimonyloP

TRAP - B

TINU - 5 sruoH 6 SEERT – :1 .spaeH ,seerT yraniB dedaerhT ,slasrevarT eerT yraniB ,seerT yraniB ,noitcudortnI

TINU – 6 sruoH 6

SEERT – :SHPARG ,2 ,steS tniojsiD fo noitatneserpeR ,stseroF ,seerT noitceleS ,seerT hcraeS yraniB.epyT ataD tcartsbA hparG ehT ,seerT yraniB gnitnuoC

TINU - 7 sruoH 6

SEUEUQ YTIROIRP elgniS - elbuoD dna - ,seerT tsitfeL ,seueuQ ytiroirP dednE ,spaeH laimoniB.spaeH gniriaP ,spaeH iccanobiF

TINU - 8 sruoH 8

:SEERT HCRAES YRANIB TNEICIFFE deR ,seerT LVA ,seerT hcraeS yraniB lamitpO - ,seerT kcalB.seerT yalpS

:kooB txeT

nosrednA ,inhaS ,ztiworoH .1 - 2 ,C ni serutcurtS ataD fo slatnemadnuF :deerF dn .7002 ,sserP seitisrevinU ,noitidE )01 ,5.9 ot 1.9 ,1.6 ,11.5 ot 5.5 ,3.5 ot 1.5 ,4 ,3 ,6.2 ot 1.2 ,1 sretpahC(

:skooB ecnerefeR

2 ,++C dna C gnisU serutcurtS ataD :muabnennaT ,nietsneguA ,haydideY .1 dn .3002 ,noitacudE nosraeP ,noitidE amaS sisabeD .2 2 ,serutcurtS ataD cissalC :atn dn .9002 ,IHP ,noitidE

egagneC ,C htiw hcaorppA edocoduesP A serutcurtS ataD :nazuoroF .A zuorheB dna grebliG .F drahciR .3.5002 ,gninraeL

itacudE nosraeP ,C ni ngiseD margorP & serutcurtS ataD :gnueL ecurB & esurK treboR .4 .7002 ,no

Page 2: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 2

STNETNOC FO ELBAT

STNETNOC FO ELBAT ................................ ................................ ................................ .............................. 1

TINU – STPECNOC CISAB :1 ................................ ................................ ................................ .................... 4

1.1 - noitacollA yromeM cimanyD dna sretnioP : ................................ ................................ ....................... 4

noitacificepS mhtiroglA .2.1 ................................ ................................ ................................ ..................... 8

noitcartsbA ataD .3.1 ................................ ................................ ................................ ................................ 9

sisylanA ecnamrofreP .4.1 ................................ ................................ ................................ ...................... 01

:tnemerusaeM ecnamrofreP .5.1 ................................ ................................ ................................ ............. 11

SNOITSEUQ DEDNEMMOCER 6.1 ................................ ................................ ................................ .... 31

TINU - SERUTCURTS dna SYARRA : 2 ................................ ................................ ................................ .. 41

YARRA 1.2 ................................ ................................ ................................ ................................ ............. 41

syarrA lanoisnemiditluM gnitacollA yllacimanyD .2.2 ................................ ................................ .......... 81

snoinU dna serutcurtS .3.2 ................................ ................................ ................................ ...................... 02

slaimonyloP. 4.2 ................................ ................................ ................................ ................................ ...... 32

secirtaM esrapS .5.2 ................................ ................................ ................................ ................................ 62

syarra lanoisnemiditluM fo noitatneserpeR .6.2 ................................ ................................ ..................... 92

SNOITSEUQ DEDNEMMOCER .7.2 ................................ ................................ ................................ ... 13

TINU – SEUEUQ DNA SKCATS : 3 ................................ ................................ ................................ ........ 23

:skcatS.1.3 ................................ ................................ ................................ ................................ ............... 23

syarrA cimanyD gnisU skcatS .2.3 ................................ ................................ ................................ ......... 43

seueuQ .3.3 ................................ ................................ ................................ ................................ .............. 43

syarrA cimanyD gnisU seueuQ ralucriC .4.3 ................................ ................................ .......................... 73

xiftsop a gnitaulavE :snoisserpxE fo noitaulavE .5.3 noisserpxe ................................ ........................... 93

seueuQ dna skcatS elpitluM .6.3 ................................ ................................ ................................ ............. 34

SEUQ DEDNEMMOCER .7.3 SNOIT ................................ ................................ ................................ ... 44

TINU – STSIL DEKNIL : 4 ................................ ................................ ................................ ...................... 54

sniahC dna stsil dekniL ylgniS .1.4 ................................ ................................ ................................ ......... 54

:C ni sniahC gnitneserpeR .2.4 ................................ ................................ ................................ ............... 64

seueuQ dna skcatS dekniL .3.4 ................................ ................................ ................................ ............... 74

:slaimonyloP .4.4 ................................ ................................ ................................ ................................ .... 94

:snoitarepo tsiL lanoitiddA .5.4 ................................ ................................ ................................ .............. 25

secirtaM esrapS .6.4 ................................ ................................ ................................ ................................ 45

Page 3: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 3

stsiL dekniL ylbuoD .7.4 ................................ ................................ ................................ ........................ 85

SNOITSEUQ DEDNEMMOCER .8.4 ................................ ................................ ................................ ... 06

TINU – SEERT : 5 – 1 ................................ ................................ ................................ ................................ 16

:noitcudortnI 1.5 ................................ ................................ ................................ ................................ ...... 16

:seerT yraniB 2.5 ................................ ................................ ................................ ................................ ..... 36

slasrevarT eert yraniB 3.5 : ................................ ................................ ................................ ...................... 56

:seert yraniB dedaerhT .4.5 ................................ ................................ ................................ ..................... 76

spaeH .5.5 ................................ ................................ ................................ ................................ ............... 76

SNOITSEUQ DEDNEMMOCER .6.5 ................................ ................................ ................................ ... 07

TINU – SEERT : 6 – SHPARG ,2 ................................ ................................ ................................ .............. 17

seerT hcraeS yraniB 1.6 ................................ ................................ ................................ .......................... 47

seerT noitceleS .2.6 ................................ ................................ ................................ ................................ . 67

stseroF 3.6 ................................ ................................ ................................ ................................ ............... 87

steS tniojsiD fo noitatneserpeR 4.6 ................................ ................................ ................................ ......... 87

:seerT yraniB gnitnuoC 5.6 ................................ ................................ ................................ ..................... 97

epyT ataD tcartsbA hparG ehT 6.6 ................................ ................................ ................................ ......... 08

SNOITSEUQ DEDNEMMOCER .7.6 ................................ ................................ ................................ ... 18

TINU – SEUEUQ YTIROIRP : 7 ................................ ................................ ................................ ............... 28

elgniS .1.7 - elbuoD dna - :seueuQ ytiroirP dednE ................................ ................................ .................... 28

:eert tsitfeL .2.7 ................................ ................................ ................................ ................................ ....... 58

spaeH laimoniB .3.7 ................................ ................................ ................................ ................................ 78

spaeH iccanobiF .4.7 ................................ ................................ ................................ ............................... 19

spaeh gniriaP .5.7 ................................ ................................ ................................ ................................ .... 59

SNOITSEUQ DEDNEMMOCER .6.7 ................................ ................................ ................................ ... 79

TINU – SEERT HCRAES YRANIB TNEICIFFE : 8 ................................ ................................ ................ 89

seerT hcraeS yraniB lamitpO .1.8 ................................ ................................ ................................ ........... 89

seerT LVA .2.8 ................................ ................................ ................................ ................................ ....... 99

deR .3.8 - seerT kcalb ................................ ................................ ................................ ............................. 301

SNOITSEUQ DEDNEMMOCER .5.8 ................................ ................................ ................................ . 911

Page 4: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 4

TINU – 1 : STPECNOC CISAB

1.1 - noitacollA yromeM cimanyD dna sretnioP :

nI ecneics retupmoc a , retniop a si egaugnal gnimmargorp epyt atad ro( ot yltcerid srefer eulav esohw" stniop eulav rehtona )"ot eht ni erehwesle derots yromem retupmoc sti gnisu sserdda roF . hgih - level

segaugnal gnimmargorp fo ecalp eht ekat ylevitceffe sretniop , lareneg sretsiger esoprup wol ni - level sa hcus segaugnal egaugnal ylbmessa ro edoc enihcam ni eb yam tub , elbaliava yromem retniop A .

secnerefer sa nwonk si ot srefer retniop a noitacol eht ta eulav eht gniniatbo dna ,yromem ni noitacol agnicnerefered is a si retniop A .retniop eht tcartsba erom eht fo noitatnemelpmi etercnoc erom ,elpm

ecnerefer om evah emos hguohtla ,retniop fo epyt emos troppus segaugnal lareveS .epyt atad er.srehto naht esu rieht no snoitcirtser

gnisrevart sa hcus snoitarepo evititeper rof ecnamrofrep evorpmi yltnacifingis atad ot sretnioP sgnirts ,selbat pukool , selbat lortnoc dna eert ecaps dna emit ni repaehc hcum netfo si ti ,ralucitrap nI .serutcurts

sretnioP.tniop sretniop eht hcihw ot atad eht ssecca dna ypoc ot si ti naht sretniop ecnerefered dna ypoc otoh ot desu osla era rof stniop yrtne fo sesserdda eht dl dellac ni senituorbus gnimmargorp larudecorp dna

rof nur - )sLLD( seirarbil knil cimanyd ot gniknil emit nI . tcejbo - gnimmargorp detneiro , ot sretniopsnoitcnuf rof desu era gnidnib sdohtem dellac era tahw gnisu netfo , selbat dohtem lautriv .

iralceD tresni ot si od ot evah uoy lla elbairav lamron na gniralced ot ralimis etiuq si elbairav retniop a gn.ti erofeb rotarepo '*' rats a

si noitaralced retniop fo mrof lareneG -

;eman *epyt

gnitniop si ti skniht retniop hcihw ot epyt eht tneserper epyt erehw .ot

resu sa llew sa denifed enihcam ot sretnioP - edam eb nac sepyt denifed

;0 = eman_retniop* epyt_elbairav :noitazilaitnI retnioP

ro

;LLUN = eman_retniop* epyt_elbairav

;"ereh eulav gnirts" = eman_retniop* rahc

ehT etniop morf eulav eht steg taht rotarepo dellac si sihT .)rotarepo noitceridni( * si elbairav r eht.retniop ot ecnerefer

a&=P

taht taht eulav eht dna a fo sserdda sah p retniop eht oS deniatnoc nac sserdda taht ni : yb dessecca eb p*

:woleb sa denialpxe eb nac ti revo enod snoitarepo eht oS

;++a

;1+a=a

;1+p*=p*

Page 5: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 5

:++)p*(

serutcurts atad ot seilppa ylreporp erom ti ,lareneg ni secnerefer ot refer ot desu neeb sah "retniop" elihW aiv yllacitemhtira( detalupinam eb ot retniop eht swolla ylticilpxe ecafretni esohw citemhtira retniop a sa )

a ot desoppo sa ,sserdda yromem eikooc cigam ro ytilibapac on si siht erehw .elbissop t

retnioP :1 giF a elbairav htiw detaicossa sserdda yromem eht ot gnitniop b ralucitrap siht ni taht etoN . emas eht sesu erutcetihcra gnitupmoc eht ,margaid aps sserdda ec dna evitimirp atad dna sretniop htob rof

non - .esac eht eb ton deen siht ;sretniop

yromeM cimanyD dna sretnioP :noitacollA

ruo fI .margorp eht fo elddim eht ni meht fo ezis eht tsujda tonnac ew ,sgniht doog era syarra hguohtlA oot si yarra llams - oot si yarra ruo fI .atad egral rof liaf lliw margorp ruo gib - ,ecaps fo tol a etsaw ew

hgir ehT .od nac ew tahw gnitcirtser niaga dna ,seceip llams morf erutcurts atad eht dliub ot si noitulos t .regral ti ekam ot deen ew revenehw eceip wen a dda sretnioP eseht dloh hcihw snoitcennoc eht era

!rehtegot seceip

efiL laeR ni sretnioP

ni sretniop sa evres srebmun enohpelet ,syaw ynam nI ton od uoy ,enoemos tcatnoc oT .yteicos s'yadot .semit lla ta uoy htiw meht yrrac ot evah rieht si deen uoy llA .rebmun ynaM evah lla nac elpoep tnereffid

.ylsuoenatlumis rebmun ruoy eht ypoc si od deen uoy llA .retniop eroM eb nac serutcurts detacilpmoc .sretniop gninibmoc yb tliub .noitamrofni yrotcerid ro seert enohp ,elpmaxe roF erom a era sesserddA

.sesserdda yromem era yllaer yeht ecnis ,sretniop rof ygolana tcerroc yllacisyhp

serutcurtS ataD dekniL

ad cimanyd eht llA eht ot retniop a deen eW .seitreporp derahs niatrec evah dliub lliw ew serutcurts at a ton ,retniop a si siht taht etoN .ti dnif nac ew os tcejbo eritne hcaE .llec atad erom ro eno sniatnoc llec

ot tnaw ew tahw si hcihw ,sdleif hcaE .erots a sniatnoc llec suhT .llec ''txen`` eno tsael ta ot dleif retniop ton si serutcurts atad deknil ni desu ecaps eht fo hcum eW !atad atad eht fo dne eht tceted ot elba eb tsum

LIN eht deen ew yhw si sihT .erutcurts sretniop .

f dradnats c ni denifed snoitcnuf ruof era erehT noitacolla yrommem cimanyd ro - ,eerf ,collac rof sdnats collaM .eerf dna collam meht fo 2 ylno era ereht AMD fo traeh eht ni tuB .collaer dna collam

nruter ot desu si eerf elihw paeh eht morf yrommem etacolla ot desu si dna snoitacolla yrommem m detacolla redaeh yrarbil dradnats a sesu snoitcnuf eseht htoB .paeh ot kcab collam morf yromme

Page 6: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 6

>h.bildts< . !!! gninraW - morf ylsuoiverp detacolla ylno yrommem eerf ot desu eb dluohs noitcnuf ) ( eerfipmoc ro denifednu ro modnar a gnieerF .collac ro collaer ,collam ot dael nac yrommem detacolla rel

.sehsarc metsys ytsan fo mrof ni ,flestI erawdraH retupmoC dna relipmoC ,.S.O eht ot egamad ereves

si noitcnuf ) ( collam fo epytotorp ehT -

)setyb_fo_rebmun t_ezis( collam* diov

a nruter collam si eron ot gniht tnatropmI sa epyt retniop yna ot detrevnoc eb nac hcihw retniop diov >h.bildts< ni denifed regetni dengisnu fo epyt laiceps a si t_ezis oslA .stniop suoiverp ni denialpxe

v a si setyb_fo_rebmun ,AMD gnisu detacolla eb nac taht ezis yrommem tsegral gnirots fo elbapac fo eula lliw ) ( collam noitcnuF .detacolla eb ot yrommem fo tnuoma eht gnitacidni regetni a yllareneg t_ezis epyt fo noiger tsrif ot retniop a nruter lliw dna sliaf noitacolla yrommem fi retniop llun a gninruter eb

si tI .llufesccus nehw detacolla yrommem ni eruliaf rof denruter retniop eht kcehc uoy dednemmocer osla yllareneg ,margorp ruoy fo ytilibats gnisaercni rof yrommem denruter eht gnisu erofeb noitacolla

en retniop denruter siht oslA .seruliaf fo esac ni edoc gnildnah rorre emos edivorp sremmargorp sdeen rev lliw dna ++C yb deriuqer si ti ecnis eno od ot ecitcarp doog a si ti ,retniop diov a si ti ecnis C ni tsacepyt a htiw desu rotarepo desu ylnommoc rehtonA.noitalipmoc rof relipmoc ++C desu uoy fi rorre a ecudorp

si hcihw rotarepo foezis si collam fo ezis eht gnimreted yb setyb_fo_rebmun fo eulav eht etaluclac ot desu.selbairav dna sepyt denifed resu sa llew sa relipmoc eht

si noitcnuf ) ( eerf fo epytotorp ehT -

)p* diov( eerf diov

mmem nruter ot desu si dna collam fo etisoppo si ) ( eerf noitcnuF AMD rehto yb detacolla ylsuoiverp yro yam uoy esiwrehto )( eerf gnisu eerf eb dluohs AMD gnisu detacolla yrommem ylno oslA .snoitcnuf

.muminim ta metsys noitacolla yrommem ruoy tpurroc

yrommem cimanyd gnisu fo dohtem elpmis swohs woleb nwohs edoc ecruoS C yltnagele noitacolla –

>h.oidts< edulcni#

>h.bildts< edulcni#

)( niam tni

{

;p* tni

noitacollA yrommeM cimanyD// ;) )tni( foezis ( collam )* tni( = p

kcolb edoc gnildnah rorre eht etucexe eruliaf noitacolla yrommem fo esacnI// )LLUN == p( fi

{

"( ftnirp \ ;)"yrommeM fo tuOn

;)1( tixe

}

;001 = p*

Page 7: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 7

"( ftnirp \ .esruocfo 001 yalpsiD// ;)p* ,"d% = p n

;0 nruter

}

noitacollA cimanyD : :wen esu ,noitacolla cimanyd teg oT

;)epytp(weN =: p

a snruter ti ,rehtruF .epytp epyt eht fo tcejbo eno yltcaxe erots ot ecaps hguone setacolla )epytp(weN na sah elbairav retniop a ,noitazilaitini ticilpxe esiwrehto ro wen a erofeB .llec ytpme siht ot retniop

ot stniop hcihw eulav yrartibra elbuort !

ninraW g - ruoy ,stnatsnoc ticilpxe ot meht ezilaitini tonnac uoy ecniS .esu erofeb sretniop lla ezilaitini era seciohc ylno

LIN - .gnihton ylticilpxe gninaem

)epytp(weN - .yromem fo knuhc hserf a

selpmaxE retnioP

:elpmaxE = :P ;)edon(wen =: q ;)edon(wen

g x.p dleif eht ot ssecca stnar x yb ot detniop drocer eht fo p .

;"cisum" =: ofni.^p

;lin =: txen.^q

.sdleif rehto eht fo yna egnahc ton seod hcihw ,deipoc eb yam flesti eulav retniop ehT

.ot tniop yeht tahw dna sretniop gningissa neewteb ecnereffid siht etoN

;q =: p

era sretnioP !kcab ti teg t'nac dna cisum ot ssecca tsol yletelpmoc evah eW .ssem laer a teg eWlanoitceridinu .

.flesti retniop eht fo daetsni ot detniop gnieb tcejbo eht ypoc dluoc ew ,ylevitanretlA

;^q =: ^p

won ew fi esac hcae ni sneppah tahW :did

;"serutcurts atad" =: ofni.^p

?morF emoC ecapS eht seoD erehW

?weN gnisu yb tsuj timil tuohtiw tnaw ew sa yromem hcum sa teg yllaer ew naC

era ew retupmoc eht fo yromem eht fo ezis eht yb desopmi stimil lacisyhp eht era ereht esuaceb ,oNsU .gnisu aludoM yllau - noitavitca`` eht fo ''edis rehto`` eht morf emoc yromem cimanyd eht tel smetsys 3

u ''kcats drocer .sllac erudecorp niatniam ot des ,stixe erudecorp a nehw yromem sesuer kcats eht sa tsuJna ti deen t'nod ew nehw delcycer eb tsum egarots cimanyd .eromy

Page 8: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 8

noitcelloC egabraG

aludoM ehT - gnikam ,detacolla sah ti hcihw yromem cimanyd eht no hctaw gnipeek yltnatsnoc si metsys 3 taht erus gnihtemos ecaps eht os ,ti ot ssecca teg ot uoy rof yaw on si ereht ,ton fI .ti ot gnitniop llits si

ehT .delcycer eb llew sa thgim rotcelloc egabrag gnihton sah hcihw yromem eht pu seerf yllacitamotuaicilpxe tuoba yrrow ot gnivah morf uoy seerf tI .ti ot gnitniop gnivael fo tsoc eht ta ,yromem gnieerf ylt

.tsil ralucric a sa hcus ,egabrag yllaer era tuo erugif t'nac ti hcihw serutcurts niatrec

noitacollaeD ticilpxE

aludoM ekil segaugnal niatrec hguohtlA - eriuqer ++C ekil srehto ,noitcelloc egabrag troppus avaJ dna 3 .ti deen t'nod uoy nehw yromem etacollaed ylticilpxe ot uoy

)p(esopsiD weN fo etisoppo eht si - yb ot detniop si hcihw tcejbo eht sekat ti p ti sekam dna rof elbaliava erutcurts deknil eritne na fo esopsid oT .tsil a ni llec eno ylno fo erac sekat esopsid hcae taht etoN .esuer

htiw elbuort otni teg nac ew etoN .emit a sa llec eno ti od tsum ew esopsid :

ti os ,cisum fo esopsid ot etal oot si ti ,esruoc fO esoppuS .noitcelloc egabrag tuohtiw reverof erudne lliw ew )p(esopsid htiw yromem cimanyd erom noitacolla retal dna , wen eb thgim fo desopsid ew llec ehT .

seod tahw woN .desuer q ?ot tniop

rewsnA - dellac oS !esle gnihtemos snaem ti tub ,noitacol emas eht secnerefer gnilgnad elbirroh a eraaludoM yhw nosaer niam eht era dna ,rorre - a ekil si ecnerefer gnilgnad A .noitcelloc egabrag stroppus 3

enoemos hcuot dna tuo hcaeR .evom uoy retfa rebmun enohp dlo ruoy htiw tfel dneirf - etanimile !secnerefer gnilgnad

avaJ ni ytiruceS

aludoM ni yromem fo esopsid ylticilpxe ot elbissop si tI - ylgnorts si ti tub ,yrassecen yllaer si ti nehw 3 si nosaer ehT .lla ta sretniop no snoitarepo hcus od ot eno wolla ton seod avaJ .degaruocsid

ytiruces ot ssecca uoy wolla sretnioP. ,elpoep live tub delliks fo sdnah eht nI .snoitacol yromem war yromem s'elpoep rehto ro s'metsys gnitarepo eht yfidom ot uoy stimrep sretniop ot ssecca dekcehcnu

.stnetnoc

mhtiroglA .2.1 noitacificepS :

dna noitacificeps mhtirogla ot hcaorppa citamgarp A sedivorp LA egaugnal ehT .detneserp si noitacifirev ,egaugnal gnimmargorp a dna noitaton noitacificeps lacitamehtam a neewteb noitcartsba fo level a

.noitpircsed mhtirogla evisserpxe tub tcapmoc gnitroppus

ni nettirw smhtirogla tuoba ssentcerroc fo sfoorP fo scitnames eht fo gniddebme na aiv enod eb nac LA ot noitalsnart hguorht enod eb nac smhtirogla fo snoitatnemelpmi ;metsys foorp a ni egaugnal eht

.segaugnal gnimmargorp dradnats

fo noitacifirev tcerid naht elbatcart erom era ssentcerroc fo sfoorp ehT ;edoc egaugnal gnimmargorp lacitamehtam dradnats naht smargorp elbatucexe ot detaler ylisae erom era LA ni snoitpircsed foorp tnereffid ot detaler eb nac hcihw noitpircsed elbatrop ,tnednepedni na sedivorp LA .snoitacificeps

immargorp tnereffid dna smetsys .segaugnal gn

otni snoitacificeps LA fo noitalsnart citamotua ylluf rof sloot dna derolpxe neeb evah secafretni lareveS sesu yduts esac laitnatsbus A .detnemelpmi neeb evah edoc elbatucexe LM dradnatS dna cigol LOH eht

ugnal noitacificeps nommoc eht sa LA dna ssentcerroc fo sfoorp lamrof eht htob hcihw morf ega.decudorp neeb evah edoc elbatucexe

Page 9: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 9

3.1 ataD . noitcartsbA noitcartsbA hcihw yb ssecorp eht si atad dna smargorp a htiw denifed era noitatneserper sti ot ralimis

em ( gnina scitnames eht yawa gnidih elihw ,) noitatnemelpmi A .sliated rotcaf dna ecuder ot seirt noitcartsb eht taht os sliated tuo remmargorp lareves evah nac metsys A .emit a ta stpecnoc wef a no sucof nac

sreyal noitcartsba na sgninaem tnereffid yberehw roF .remmargorp eht ot desopxe era liated fo stnuoma d ,elpmaxe wol - level eht fo sliated esopxe sreyal noitcartsba erawdrah si margorp eht erehw nur elihw ,

hgih - eht htiw laed sreyal level cigol ssenisub .margorp eht fo

retupmoc ot seilppa mret siht woh dnatsrednu ot spleh noitcartsba fo noitinifed hsilgnE gniwollof ehT:stcejbo dna TI ,ecneics

noitcartsba - ecnatsni cificeps yna htiw detaicossa ton aedi ro tpecnoc a ]1[

ehT .evitcepsrep tnerruc eht ot tnaveler era taht tcejbo na tuoba liated esoht ylno serutpac noitcartsbA htiw ygolana yb detanigiro tpecnoc scitamehtam ni noitcartsba fo euqinhcet lacitamehtam ehT .

lacitamehtam htiw snigeb noitcartsba snoitinifed lareneg eht naht hcaorppa lacinhcet erom a ti gnikam , fo tpecnoc yhposolihp ni noitcartsba ,scitamehtam ni dna gnitupmoc htob ni ,elpmaxe roF . srebmun era

eht ni stpecnoc segaugnal gnimmargorp no dneped sliated noitatnemelpmI .scitamehtam ni dednuof sa ,ht tub ,erawtfos dna erawdrah eht llits si rebmun fo tpecnoc gnitupmoc eht esuaceb noitcirtser a ton si si

.tpecnoc lacitamehtam eht no desab

nI gnimmargorp retupmoc lortnoc ot ylppa nac noitcartsba , :atad ot ro noitcartsba lortnoC eht si elihw snoitca fo noitcartsba noitcartsba atad esu eht sevlovni noitcartsba lortnoC .serutcurts atad fo taht si

fo smargorpbus stpecnoc detaler dna swolf lortnoc ni stib atad gnildnah swolla noitcartsba ataD . dniheb noitavitom cisab eht si ti ,elpmaxe roF .syaw lufgninaem epytatad na fo noiton eht drager nac enO .

tcejbo morf( tcejbo - gnimmargorp detneiro ehT .edoc dna atad fo snoitcartsba enibmoc ot tpmetta na sa ) nommoc a sa desu eb nac noitinifed tcartsba emas ecafretni tnereffid htiw stcejbo fo ylimaf a rof

ehT .gninaem emas eht erahs hcihw tub sroivaheb dna snoitatnemelpmi ecnatirehni ahcem tcejbo ni msin - na enifed ot desu eb nac gnimmargorp detneiro ssalc tcartsba .ecafretni nommoc eht sa

rapes raelc a secrofne noitcartsba ataD eht neewteb noita tcartsba a fo seitreporp epyt atad eht dnaetercnoc taht edoc tneilc ot elbisiv era taht esoht era seitreporp tcartsba ehT .noitatnemelpmi sti fo sliated

epyt atad eht fo esu sekam — eht ecafretni epyt atad eht ot — tpek si noitatnemelpmi etercnoc eht elihw elpmaxe rof ,egnahc nac deedni dna ,etavirp yleritne .emit revo stnemevorpmi ycneiciffe etaroprocni ot

on evlovni yeht ecnis ,edoc tneilc no tcapmi yna evah ot desoppus ton era segnahc hcus taht si aedi ehT .ruoivaheb tcartsba eht ni ecnereffid

na enifed dluoc eno ,elpmaxe roF epyt atad tcartsba dellac elbat pukool setaicossa yleuqinu hcihw syek htiw seulav pukool a hcuS .syek gnidnopserroc rieht gniyficeps yb deveirter eb yam seulav hcihw ni dna ,

i detnemelpmi eb yam elbat a sa :syaw suoirav n elbat hsah a , eert hcraes yranib raenil elpmis a neve ro ,tsil emas eht era epyt eht fo seitreporp tcartsba eht ,denrecnoc si edoc tneilc sa raf sA .sriap )eulav:yek( fo

cafretni eht fo sliated eht gnitteg no seiler lla siht ,esruoc fO .esac hcae ni ecnis ,ecalp tsrif eht ni thgir e a smrof ecafretni eht :siht ta kool ot yaw eno sA .edoc tneilc no stcapmi rojam evah nac ereht segnahc yna

tcartnoc eht ni tuo delleps ton gnihtyna ;edoc tneilc dna epyt atad eht neewteb ruoivaheb deerga nobus si tcartnoc .eciton tuohtiw egnahc ot tcej

edulcni noitcartsba atad tnemelpmi taht segaugnaL adA dna doM alu -2 . tcejbO - detneiro era segaugnaldemialc ylnommoc rieht ,revewoh ;noitcartsba atad reffo ot ecnatirehni noitamrofni tup ot sdnet tpecnoc

sdne noitamrofni hcus ot segnahc ,suht ;noitatnemelpmi eht ni sgnoleb ylreporp erom taht ecafretni eht ni eht ot yltcerid gnidael ,edoc tneilc gnitcapmi pu melborp ecafretni yranib eligarF .

Page 10: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 01

4.1 ecnamrofreP . sisylanA :

srosnops dna sremotsuc pleh ot atad lamrofni dna lamrof gnirehtag sevlovni sisylana ecnamrofreP enifed ,ytinutroppo ro melborp a no sevitcepsrep lareves srevocnu sisylana ecnamrofreP .slaog rieht eveihca dna noitulos a gnisoporp dna ,ecnamrofrep lufsseccus ot sreirrab ro sdrawot srevird lla dna yna gninimreted

.derevocsid si tahw no desab metsys

il A :si noitinifed rethg

emoS .od ot tahw tuo erugif ot od ew tahw s'tI .dne tnorf eht fo dne tnorf eht si sisylana ecnamrofreP.scitsongaid dna ,gnitidua ,gnipocs ,gninnalp era smynonys

?od tsylana ecnamrofrep a seod tahW

y sgniht eht fo emos fo tsil a s'ereH uo yam eb :sisylana ecnamrofrep a fo trap sa gniod

rosnops a gniweivretnI troper launna eht gnidaeR sevitatneserper ecivres remotsuc fo puorg a htiw hcnul ta gnittahC noitingocer eht no ylralucitrap gnisucof ,ecivres remotsuc no ycilop s'noitazinagro eht gnidaeR

stcepsa evitnecni dna stnialpmoc ecivres remotsuc htiw setaicossa sepatoidua ot gninetsiL srosivrepus htiw puorg sucof a gnidaeL d ylmodnar emos gniweivretnI sevitatneserper nwar gol llac eht gniweiveR ecnamrofrep ecivres remotsuc fo tcejbus eht no lanruoj lanoisseforp a ni elcitra na gnidaeR

tnemevorpmi reh tuoba uoy llet ot stnaw ohw ,remotsuc a si ohw ydobemos htiw tekramrepus eht ta gnittahC

w ecneirepxe ecivres remotsuc hti

:ssecorp sisylana ecnamrofrep eht ni spets cisab eerht hsiugnitsid eW

,noitcelloc atad dna ,noitamrofsnart atad .noitazilausiv atad

noitcelloc ataD na morf deniatbo era ecnamrofrep margorp tuoba atad hcihw yb ssecorp eht siexe ,noitucexe retfa ro gnirud rehtie ,elif a ni detcelloc yllamron era ataD .margorp gnituc

.emit laer ni resu eht ot detneserp eb yam ti snoitautis emos ni hguohtla

:dehsiugnitsid eb nac seuqinhcet noitcelloc atad cisab eerhT

seliforP tnuoma eht drocer hguoht ,noitamrofni sihT .margorp a fo strap tnereffid ni tneps emit fo .smelborp ecnamrofrep gnithgilhgih rof elbaulavni netfo si ,laminim derehtag era yllacipyt seliforP

.yllacitamotua

sretnuoC .semit evitalumuc ro stneve fo seicneuqerf rehtie drocer eriuqer yam sretnuoc fo noitresni ehT .noitnevretni remmargorp emos

secart tnevE tnuoma egral a gnicudorp yllacipyt suht ,stneve deificeps suoirav fo ecnerrucco hcae drocer .atad fo vretni remmargorp htiw ro yllacitamotua rehtie decudorp eb nac secarT .noitne

Page 11: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 11

rewsna ot deriuqer mrof eht ni ylerar era secart ro ,sretnuoc ,seliforp yb decudorp atad war ehT ,ecneH .snoitseuq ecnamrofrep atad snoitamrofsnart gnicuder fo laog eht htiw netfo ,deilppa era

latot ot desu eb nac snoitamrofsnarT .emulov atad rehgih rehto ro seulav naem enimreted - scitsitats redro hcae ni tneps emit eht gnidrocer eliforp a ,elpmaxe roF .secart morf atad retnuoc dna eliforp tcartxe ot ro

us hcae ni tneps emit naem eht enimreted ot demrofsnart eb thgim rossecorp hcae no enituorbus enituorb ot dessecorp eb nac ecart a ,ylralimiS .naem siht morf noitaived dradnats eht dna ,rossecorp hcae no sloot ecnamrofrep suoirav eht fo hcaE .sezis egassem fo noitubirtsid eht gnivig margotsih a ecudorp

setaroprocni snoitces tneuqesbus ni debircsed tliub fo tes emos - dezilaiceps erom ;snoitamrofsnart ni .remmargorp eht yb dedoc eb osla nac noitamrofsnart

noitacinummoc ,semit noitucexe fo gnitsisnoc ,lanoisnemiditlum yltnerehni era atad ecnamrofrep lellaraPopmoc margorp elpitlum rof ,no os dna ,stsoc melborp tnereffid rof dna ,srossecorp tnereffid no ,stnen

ot atad ecnamrofrep sserpmoc ot snoitautis emos ni desu eb nac seuqinhcet noitcuder atad hguohtlA .sezis sA .atad lanoisnemiditlum war eht erolpxe ot elba eb ot yrassecen netfo si ti ,seulav ralacs si nwonk llew

fo esu eht morf ylsuomrone tifeneb nac ssecorp siht ,gnireenigne dna ecneics lanoitatupmoc ni atadnoitazilausiv ot deilppa eb nac seuqinhcet yalpsid dezilaiceps erom dna lanoitnevnoc htoB .seuqinhcet

.atad ecnamrofrep

w a ,ees llahs ew sA .elbaliava era sloot noitazilausiv dna ,noitamrofsnart ,noitcelloc atad fo yteirav edi :deredisnoc eb dluohs seussi gniwollof eht ,ksat ralucitrap a rof loot a gnitceles nehW

.ycaruccA atad naht etarucca ssel era seuqinhcet gnilpmas gnisu deniatbo atad ecnamrofrep ,lareneg nI otni nekat eb tsum kcolc eht fo ycarucca eht ,sremit fo esac eht nI .sremit ro sretnuoc gnisu yb deniatbo

.tnuocca

.yticilpmiS ecnatsmucric ynam ni sloot tseb ehT on ro elttil htiw ,yllacitamotua atad tcelloc taht esoht era s .seitilibapac sisylana tneinevnoc edivorp taht dna ,noitnevretni remmargorp

.ytilibixelF edivorp ot ro atad ecnamrofrep lanoitidda tcelloc ot ylisae dednetxe eb nac loot elbixelf Av tnereffid .stnemeriuqer gnisoppo netfo era yticilpmis dna ytilibixelF .atad emas eht fo swei

.ssenevisurtnI ylbativeni noitcelloc atad ecnamrofrep ,troppus erawdrah sedivorp retupmoc a sselnUnuocca dna daehrevo siht fo erawa eb ot deen eW .daehrevo emos secudortni .atad gnizylana nehw ti rof t

.noitcartsbA rof etairporppa noitcartsba fo level a ta denimaxe eb ot atad swolla loot ecnamrofrep doog A a morf ecart noitucexe na gnizylana nehw ,elpmaxe roF .margorp lellarap eht fo ledom gnimmargorp eht

egassem - m laudividni ees ot hsiw ylbaborp ew ,margorp gnissap eb nac yeht fi ylralucitrap ,segasse ylbaborp si noitatneserp siht ,revewoH .margorp ecruos eht ni stnemetats eviecer dna dnes ot detaler ton

atad a gniyduts nehw etairporppa - egassem a setareneg noitalipmoc fi neve ,margorp lellarap - gnissapaetsnI .margorp atad ot detaler stsoc noitacinummoc ees ot ekil dluow ew ,d - .stnemetats margorp lellarap

:tnemerusaeM ecnamrofreP .5.1 tnemerusaem ecnamrofreP nihtiw sretemarap eht sehsilbatse noitazinagro na yberehw ssecorp eht si

iuqca dna ,stnemtsevni ,smargorp hcihw .stluser derised eht gnihcaer era snoitis

:serusaeM ecnamrofreP dooG

gnikrow si ygetarts ruo fi ees ot yaw a edivorP

sseccus ot tsom srettam tahw no noitnetta 'seeyolpme sucoF

Page 12: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 21

demrofrep si taht krow eht fo tsuj ton ,stnemhsilpmocca fo tnemerusaem wollA

rP noitacinummoc rof egaugnal nommoc a edivo

detcepxe ,ytilauq atad ,ycneuqerf noitcelloc ,erusaem fo tinu ,renwo fo smret ni denifed ylticilpxe erAsdlohserht dna ,)stegrat(eulav

sgniht thgir eht fo tnemerusaem erusne ot ,dilav erA

erusne ot ,elbaifirev erA ycarucca noitcelloc atad

XE -

eht fo ledoM ecnerefeR ecnamrofreP erutcetihcrA esirpretnE laredeF ,

fo ssecorp sihT gnirusaem fo esu eht seriuqer netfo ecnamrofrep lacitsitats ssergorp enimreted ot ecnedivevitcejbo lanoitazinagro denifed cificeps drawot gnidliub latnemadnuf a si tnemerusaem ecnamrofreP .se

.noitazinagro ytilauq latot a dna MQT fo kcolb

laicnanif eht hguorht yaw emos ni ecnamrofrep derusaem syawla evah snoitasinagro ,yllacirotsiHil hguorht eruliaf ro tiforp yb sseccus siht eb ,ecnamrofrep ecnamrofrep lanoitidart ,revewoH .noitadiuq

ytilauq rieht no snoitazinagro troppus ot elttil edivorp ,noitamrofni gnitnuocca tsoc no desab ,serusaem a nI .remotsuc eht yb nees stnemevorpmi dna ecnamrofrep ssecorp pam ton od yeht esuaceb ,yenruoj

lufsseccus eht yb nees stnemevorpmi eht yb derusaem eb lliw ecnamrofrep ,noitasinagro ytilauq latot.sredloherahs eht sa hcus ,sredlohekats rehto ot dereviled stluser eht yb sa llew sa remotsuc

llof si sihT .tnatropmi si ecnamrofrep gnirusaem yhw srevoc noitces sihT fo tsoc fo noitpircsed a yb dewo esiar dna seitivitca tnemevorpmi evird ot sraey ynam rof desu neeb sah hcihw ,tnemerusaem ytilauq

.noitasinagro na ni smelborp ytilauq fo tceffe eht fo ssenerawa

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 21

demrofrep si taht krow eht fo tsuj ton ,stnemhsilpmocca fo tnemerusaem wollA

rP noitacinummoc rof egaugnal nommoc a edivo

detcepxe ,ytilauq atad ,ycneuqerf noitcelloc ,erusaem fo tinu ,renwo fo smret ni denifed ylticilpxe erAsdlohserht dna ,)stegrat(eulav

sgniht thgir eht fo tnemerusaem erusne ot ,dilav erA

erusne ot ,elbaifirev erA ycarucca noitcelloc atad

XE -

eht fo ledoM ecnerefeR ecnamrofreP erutcetihcrA esirpretnE laredeF ,

fo ssecorp sihT gnirusaem fo esu eht seriuqer netfo ecnamrofrep lacitsitats ssergorp enimreted ot ecnedivevitcejbo lanoitazinagro denifed cificeps drawot gnidliub latnemadnuf a si tnemerusaem ecnamrofreP .se

.noitazinagro ytilauq latot a dna MQT fo kcolb

laicnanif eht hguorht yaw emos ni ecnamrofrep derusaem syawla evah snoitasinagro ,yllacirotsiHil hguorht eruliaf ro tiforp yb sseccus siht eb ,ecnamrofrep ecnamrofrep lanoitidart ,revewoH .noitadiuq

ytilauq rieht no snoitazinagro troppus ot elttil edivorp ,noitamrofni gnitnuocca tsoc no desab ,serusaem a nI .remotsuc eht yb nees stnemevorpmi dna ecnamrofrep ssecorp pam ton od yeht esuaceb ,yenruoj

lufsseccus eht yb nees stnemevorpmi eht yb derusaem eb lliw ecnamrofrep ,noitasinagro ytilauq latot.sredloherahs eht sa hcus ,sredlohekats rehto ot dereviled stluser eht yb sa llew sa remotsuc

llof si sihT .tnatropmi si ecnamrofrep gnirusaem yhw srevoc noitces sihT fo tsoc fo noitpircsed a yb dewo esiar dna seitivitca tnemevorpmi evird ot sraey ynam rof desu neeb sah hcihw ,tnemerusaem ytilauq

.noitasinagro na ni smelborp ytilauq fo tceffe eht fo ssenerawa

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 21

demrofrep si taht krow eht fo tsuj ton ,stnemhsilpmocca fo tnemerusaem wollA

rP noitacinummoc rof egaugnal nommoc a edivo

detcepxe ,ytilauq atad ,ycneuqerf noitcelloc ,erusaem fo tinu ,renwo fo smret ni denifed ylticilpxe erAsdlohserht dna ,)stegrat(eulav

sgniht thgir eht fo tnemerusaem erusne ot ,dilav erA

erusne ot ,elbaifirev erA ycarucca noitcelloc atad

XE -

eht fo ledoM ecnerefeR ecnamrofreP erutcetihcrA esirpretnE laredeF ,

fo ssecorp sihT gnirusaem fo esu eht seriuqer netfo ecnamrofrep lacitsitats ssergorp enimreted ot ecnedivevitcejbo lanoitazinagro denifed cificeps drawot gnidliub latnemadnuf a si tnemerusaem ecnamrofreP .se

.noitazinagro ytilauq latot a dna MQT fo kcolb

laicnanif eht hguorht yaw emos ni ecnamrofrep derusaem syawla evah snoitasinagro ,yllacirotsiHil hguorht eruliaf ro tiforp yb sseccus siht eb ,ecnamrofrep ecnamrofrep lanoitidart ,revewoH .noitadiuq

ytilauq rieht no snoitazinagro troppus ot elttil edivorp ,noitamrofni gnitnuocca tsoc no desab ,serusaem a nI .remotsuc eht yb nees stnemevorpmi dna ecnamrofrep ssecorp pam ton od yeht esuaceb ,yenruoj

lufsseccus eht yb nees stnemevorpmi eht yb derusaem eb lliw ecnamrofrep ,noitasinagro ytilauq latot.sredloherahs eht sa hcus ,sredlohekats rehto ot dereviled stluser eht yb sa llew sa remotsuc

llof si sihT .tnatropmi si ecnamrofrep gnirusaem yhw srevoc noitces sihT fo tsoc fo noitpircsed a yb dewo esiar dna seitivitca tnemevorpmi evird ot sraey ynam rof desu neeb sah hcihw ,tnemerusaem ytilauq

.noitasinagro na ni smelborp ytilauq fo tceffe eht fo ssenerawa

Page 13: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 31

cihw ,deniltuo si krowemarf tnemerusaem ecnamrofrep elpmis A tub ,gnirusaem tsuj naht erom sedulcni h gnikat dna gnisitiroirp neht ,atad gnisylana dna gnitcelloc ,scirtem gnidnatsrednu dna gninifed osla

.derevoc osla si hcaorppa dracerocs decnalab eht fo noitpircsed A .snoitca tnemevorpmi

?ecnamrofrep erusaem yhW

gnihtemos wonk uoy ,srebmun ni ti sserpxe dna tuoba gnikaeps era uoy tahw erusaem nac uoy nehW‘.’ti tuoba

.’erusaem tonnac uoy tahw eganam tonnac uoY‘

netfo owt era esehT - si ti teY .tnatropmi si tnemerusaem yhw etartsnomed taht stnemetats detouqnisirprus .eganam ot tluciffid os tnemerusaem fo aera eht dnif snoitasinagro taht g

reven fo elcyc eht nI - :ni elor tnatropmi na syalp tnemerusaem ecnamrofrep ,tnemevorpmi gnidne

slaog lanoitasinagro tsniaga ssergorp gnikcart dna gniyfitnedI •

gniyfitnedI • tnemevorpmi rof seitinutroppo

sdradnats lanretxe dna lanretni htob tsniaga ecnamrofrep gnirapmoC •

fo noitcerid eht gnitalumrof nehw pets tnatropmi na osla si noitasinagro na fo ecnamrofrep eht gniweiveRhw wonk ot tnatropmi si tI .seitivitca cigetarts eht ,eil noitasinagro eht fo sessenkaew dna shtgnerts eht ere

eht fo trap sa dna nalP‘ – oD – kcehC – ’tcA dna ytilauq ni elor yek a syalp tnemerusaem ,elcyc:era dedeen si ti snosaer niam ehT .seitivitca tnemevorpmi ytivitcudorp

nemeriuqer remotsuc erusne oT • st evah tem neeb

elbisnes tes ot elba eb oT • sevitcejbo meht htiw ylpmoc dna

edivorp oT • sdradnats snosirapmoc gnihsilbatse rof

edivorp oT • ytilibisiv ot elpoep rof ”draoberocs“ a dna rotinom level ecnamrofrep nwo rieht

thgilhgih oT • smelborp ytilauq a rof saera enimreted dn noitnetta ytiroirp

edivorp oT • kcabdeef troffe tnemevorpmi eht gnivird rof

no ,ecnamrofrep ssenisub ni stnemevorpmi no MQT fo tcapmi eht dnatsrednu ot tnatropmi osla si tIced elbissop yna gnicuder dna ecnamrofrep tnerruc gniniatsus ecnamrofrep ni enil .

6.1 DEDNEMMOCER SNOITSEUQ .1 ?serutcurtS ataD enifeD

?elbairav retniop a si tahW.2

3. ?erutcurtS ataD dna epyT ataD ,epyT ataD tcartsbA neewteb ecnereffiD

?)TDA( epyT ataD tcartsbA na enifeD .4

5 dna segatnavda 2 yna eviG . sretniop gnisu fo segatnavdasid ?

Page 14: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 41

TINU -2 : SERUTCURTS dna SYARRA YARRA 1.2 :

: noitinifeD .epyt atad emas eht sah hcihw stnemele elpitlum dloh taht elbairav a si noitinifed yb yarrA

: syarrA gniralceD

sdloh yarra eht stnemele fo rebmun eht dna eman ,epyt atad sti yficeps yb yarra na eralced nac eW :xatnys eht si ereH .eman yarra eht gniwollof yletaidemmi stekcarb erauqs neewteb

1 ;]ezis[eman_yarra epyt_atad

ihw yarra regetni na eralced ot ,elpmaxe roF :swollof sa od nac ew stnemele 001 sniatnoc hc

1 tni ;]001[a

erutcurts gnidulcni sepyt atad C dilav yna eb nac epyt atad ehT .noitaralced yarra no selur emos era erehT evitisop a eb ot sah yarra fo ezis eht dna elbairav fo elur eht wollof ot sah eman yarra ehT .noinu dna

stnemele yarra ssecca nac eW.regetni tnatsnoc sexedni aiv ]xedni[eman_yarra strats yarra fo sexednI . si yarra na fo stnemele tsehgih eht os 1 ton 0 morf ezis[eman_yarra - ]1

: syarrA gnizilaitinI

hcihw seulav gnizilaitini edivorp uoy ,yarra na ezilaitini oT .dezilaitini eb nac yarra na ,elbairav a ekil si tI yarra eht retfa ngis slauqe na gniwollof decalp dna noitaralced eht ni secarb ylruc nihtiw desolcne era

izilaitini fo elpmaxe na si ereH .eman .yarra regetni na gn

tni ;}8,7,3,1,2{ = ]5[tsil

noitatneserpeR yarrA

.snoitatnemelpmi elpmis eriuqer snoitarepO emit raenil eriuqer ,hcraes dna ,eteled ,tresnI ecaps fo esu tneiciffenI

ylno eht netfo si yarra ehT .yarra eht htiw serutcurts atad fo yduts ruo nigeb ew taht etairporppa si tI a sevresed ti eroferehT .egaugnal gnimmargorp a ni dedivorp si hcihw atad gnirutcurts rof snaem

fo puorg a sksa eno fI .noitnetta fo tnuoma tnacifingis netfo tsom eht ,yarra na enifed ot sremmargorp a :si gniyas detouq .snoitacol yromem fo tes evitucesnoc a slaever ylraelc ti esuaceb etanutrofnu si sihT

tI .noitatneserper sti dna erutcurts atad a neewteb noitcnitsid eht yleman ,noisufnoc fo tniop nommoc si .syawla ton tub ,yromem evitucesnoc gnisu yb detnemelpmi syawla tsomla era syarra taht eurt eulav a si ereht ,denifed si hcihw xedni hcae roF .eulav dna xedni ,sriap fo tes a si yarra na ,ylevitiutnI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 41

TINU -2 : SERUTCURTS dna SYARRA YARRA 1.2 :

: noitinifeD .epyt atad emas eht sah hcihw stnemele elpitlum dloh taht elbairav a si noitinifed yb yarrA

: syarrA gniralceD

sdloh yarra eht stnemele fo rebmun eht dna eman ,epyt atad sti yficeps yb yarra na eralced nac eW :xatnys eht si ereH .eman yarra eht gniwollof yletaidemmi stekcarb erauqs neewteb

1 ;]ezis[eman_yarra epyt_atad

ihw yarra regetni na eralced ot ,elpmaxe roF :swollof sa od nac ew stnemele 001 sniatnoc hc

1 tni ;]001[a

erutcurts gnidulcni sepyt atad C dilav yna eb nac epyt atad ehT .noitaralced yarra no selur emos era erehT evitisop a eb ot sah yarra fo ezis eht dna elbairav fo elur eht wollof ot sah eman yarra ehT .noinu dna

stnemele yarra ssecca nac eW.regetni tnatsnoc sexedni aiv ]xedni[eman_yarra strats yarra fo sexednI . si yarra na fo stnemele tsehgih eht os 1 ton 0 morf ezis[eman_yarra - ]1

: syarrA gnizilaitinI

hcihw seulav gnizilaitini edivorp uoy ,yarra na ezilaitini oT .dezilaitini eb nac yarra na ,elbairav a ekil si tI yarra eht retfa ngis slauqe na gniwollof decalp dna noitaralced eht ni secarb ylruc nihtiw desolcne era

izilaitini fo elpmaxe na si ereH .eman .yarra regetni na gn

tni ;}8,7,3,1,2{ = ]5[tsil

noitatneserpeR yarrA

.snoitatnemelpmi elpmis eriuqer snoitarepO emit raenil eriuqer ,hcraes dna ,eteled ,tresnI ecaps fo esu tneiciffenI

ylno eht netfo si yarra ehT .yarra eht htiw serutcurts atad fo yduts ruo nigeb ew taht etairporppa si tI a sevresed ti eroferehT .egaugnal gnimmargorp a ni dedivorp si hcihw atad gnirutcurts rof snaem

fo puorg a sksa eno fI .noitnetta fo tnuoma tnacifingis netfo tsom eht ,yarra na enifed ot sremmargorp a :si gniyas detouq .snoitacol yromem fo tes evitucesnoc a slaever ylraelc ti esuaceb etanutrofnu si sihT

tI .noitatneserper sti dna erutcurts atad a neewteb noitcnitsid eht yleman ,noisufnoc fo tniop nommoc si .syawla ton tub ,yromem evitucesnoc gnisu yb detnemelpmi syawla tsomla era syarra taht eurt eulav a si ereht ,denifed si hcihw xedni hcae roF .eulav dna xedni ,sriap fo tes a si yarra na ,ylevitiutnI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 41

TINU -2 : SERUTCURTS dna SYARRA YARRA 1.2 :

: noitinifeD .epyt atad emas eht sah hcihw stnemele elpitlum dloh taht elbairav a si noitinifed yb yarrA

: syarrA gniralceD

sdloh yarra eht stnemele fo rebmun eht dna eman ,epyt atad sti yficeps yb yarra na eralced nac eW :xatnys eht si ereH .eman yarra eht gniwollof yletaidemmi stekcarb erauqs neewteb

1 ;]ezis[eman_yarra epyt_atad

ihw yarra regetni na eralced ot ,elpmaxe roF :swollof sa od nac ew stnemele 001 sniatnoc hc

1 tni ;]001[a

erutcurts gnidulcni sepyt atad C dilav yna eb nac epyt atad ehT .noitaralced yarra no selur emos era erehT evitisop a eb ot sah yarra fo ezis eht dna elbairav fo elur eht wollof ot sah eman yarra ehT .noinu dna

stnemele yarra ssecca nac eW.regetni tnatsnoc sexedni aiv ]xedni[eman_yarra strats yarra fo sexednI . si yarra na fo stnemele tsehgih eht os 1 ton 0 morf ezis[eman_yarra - ]1

: syarrA gnizilaitinI

hcihw seulav gnizilaitini edivorp uoy ,yarra na ezilaitini oT .dezilaitini eb nac yarra na ,elbairav a ekil si tI yarra eht retfa ngis slauqe na gniwollof decalp dna noitaralced eht ni secarb ylruc nihtiw desolcne era

izilaitini fo elpmaxe na si ereH .eman .yarra regetni na gn

tni ;}8,7,3,1,2{ = ]5[tsil

noitatneserpeR yarrA

.snoitatnemelpmi elpmis eriuqer snoitarepO emit raenil eriuqer ,hcraes dna ,eteled ,tresnI ecaps fo esu tneiciffenI

ylno eht netfo si yarra ehT .yarra eht htiw serutcurts atad fo yduts ruo nigeb ew taht etairporppa si tI a sevresed ti eroferehT .egaugnal gnimmargorp a ni dedivorp si hcihw atad gnirutcurts rof snaem

fo puorg a sksa eno fI .noitnetta fo tnuoma tnacifingis netfo tsom eht ,yarra na enifed ot sremmargorp a :si gniyas detouq .snoitacol yromem fo tes evitucesnoc a slaever ylraelc ti esuaceb etanutrofnu si sihT

tI .noitatneserper sti dna erutcurts atad a neewteb noitcnitsid eht yleman ,noisufnoc fo tniop nommoc si .syawla ton tub ,yromem evitucesnoc gnisu yb detnemelpmi syawla tsomla era syarra taht eurt eulav a si ereht ,denifed si hcihw xedni hcae roF .eulav dna xedni ,sriap fo tes a si yarra na ,ylevitiutnI

Page 15: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 51

ew smret lacitamehtam nI .xedni taht htiw detaicossa ,revewoH .gnippam a ro ecnednopserroc a siht llac hcihw snoitarepo eht gnivig yb noitinifed lanoitcnuf erom a edivorp ot tnaw ew stsitneics retupmoc sa snoitarepo owt ylno htiw denrecnoc era ew snaem siht syarra roF .erutcurts atad siht no dettimrep era

hw :sa denifed eb nac tcejbo siht noitaton ruo gnisU .seulav erots dna eveirter hci

erutcurts YARRA ( xedni ,eulav ) eralced ETAERC ) ( yarra

EVEIRTER ( xedni,yarra ) eulav EROTS ( eulav,xedni,yarra ) ;yarra lla rof A j,i ,yarra x ,xedni eulav tel

EVEIRTER ( TAERC E,i = :: ) rorre EVEIRTER ( EROTS ( x,i,A ) j, = :: )

fi LAUQE ( j,i ) neht x esle EVEIRTER ( j,A ) dne dne YARRA

,xedni na dna yarra na tupni sa sekat EVEIRTER .yarra ytpme ,wen a secudorp ETAERC noitcnuf ehTxedni wen retne ot desu si EROTS .rorre na ro eulav etairporppa eht snruter rehtie dna - ehT .sriap eulav

eht eveirter ot" sa daer si moixa dnoces j- erehw meti ht x xedni ta derots neeb ydaerla sah i ni A si fi gnikcehc ot tnelaviuqe i dna j ,os fi dna lauqe era ,x eht rof hcraes ro j- ,yarra gniniamer eht ni eulav ht

.A yna fo tnednepedni era smoixa eht woh ecitoN .yhtraCcM .J yb nevig yllanigiro saw moixa sihT "er ,oslA .emehcs noitatneserp i dna j na taht ylno emussa ew tub ,sregetni eb ylirassecen ton deen

.desived eb nac noitcnuf LAUQE

ew yromem ssecca modnar lanoitnevnoc a gnimussa neht ,sregetni eb ot seulav xedni eht tcirtser ew fITER dna EROTS tnemelpmi nac terpretni ew fI .emit fo tnuoma tnatsnoc a ni etarepo yeht taht os EVEIR

eb ot secidni eht n- ( ,lanoisnemid i1 i, 2 i,... , n enifed dna yletaidemmi ylppa smoixa suoiverp eht neht ,) n- EVEIRTER tnemelpmi ot woh enimaxe lliw ew 4.2 noitces nI .syarra lanoisnemid itlum rof EROTS dna -

.snoitacol yromem evitucesnoc gnisu syarra lanoisnemid :retnioP dna yarrA

eht ot stniop taht retniop a si eman yarra dna snoitacol yromem evitucesnoc seipucco tnemele yarra hcaE nac ew xedni aiv yarra gnissecca ediseB .tnemele tsrif margorp sihT .yarra etalupinam ot retniop esu

gnisu tnemele yarra ssecca ot woh dna stnemele yarra hcae sserdda yromem eht ezilausiv uoy spleh.retniop

10 >h.oidts< edulcni#

20

30 diov )(niam

40 {

50

60 tsnoc tni ;5 = ezis

Page 16: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 61

70

80 tni ;}8,7,3,1,2{ = ]ezis[tsil

90

01 ;tsil = tsilp *tni

11

21 stnemele yarra fo sserdda yromem tnirp //

31 tni(rof )++i;ezis < i ;0 = i

41 {

51 d% ni si ]d%[tsil"(ftnirp \ ;)]i[tsil&,i,"n

61

71 }

81

91 retniop gnisu stnemele yarra gnissecca //

02 )++i;ezis < i ;0 = i(rof

12 {

22 d% = ]d%[tsil"(ftnirp \ ;)tsilp*,i,"n

32

42 txen eht ot og ti os retniop fo sserdda yromem esaercni */

52 /* yarra eht fo tnemele

62 ;++tsilp

72 }

82

92 }

tuptuo eht si ereH

Page 17: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 71

8650131 ni si ]0[tsil 2750131 ni si ]1[tsil 6750131 ni si ]2[tsil 0850131 ni si ]3[tsil 4850131 ni si ]4[tsil 2 = ]0[tsil 1 = ]1[tsil 3 = ]2[tsil

= ]3[tsil 7 8 = ]4[tsil

na sesu teppins edoc sihT .sretniop fo yarra na evah ew esac siht ni dna yarra na ni sretniop erots nac uoY.retniop regetni erots ot yarra

1 tni ;]01[pa*

:syarrA lanoisnemiditluM

iditlum a dellac si eulav xedni eno naht erom htiw yarra nA si evoba yarra eritne ehT .yarra lanoisnemelgnis dellac - xatnys wollof od nac uoy yarra lanoisnemiditlum a eralced oT .yarra lanoisnemid

1 ;][][][eman_yarra epyt_atad

owt eralced ot elpmaxe roF .yarra eht fo noisnemid eht seificeps stekcarb erauqs fo rebmun ehT :swollof sa od nac ew yarra regetni snoisnemid

1 tni ;]3[]3[xirtam

: syarrA lanoisnemiditluM gnizilaitinI

elgnis a sa yarra na ezilaitini nac uoY - noisnemid owt na ezilaitini fo elpmaxe na si ereH .yarra:yarra regetni snoisnemid

1 tni = ]3[]3[xirtam

2 {

3 ,}31,21,11{

4 ,}32,22,12{

5 ,}33,13,23{

6 ;}

syarrA detacollA yllacimanyD enO : - syarrA lanoisnemiD

elipmoc ta denifed stnetxe rieht evah tsum syarra ,C nI - fo noitinifed eht enoptsop ot yaw on s'erehT .emit dna sretniop htiw ,ylikcuL .emitnur litnu yarra na fo ezis eht collam .noitatimil siht dnuora krow nac ew ,

Page 18: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 81

eno a etacolla oT - el fo yarra lanoisnemid htgn N esu ylpmis ,epyt ralucitrap emos fo collam etacolla ot dloh ot yromem hguone N erew ti fi sa retniop gnitluser eht esu neht dna ,epyt ralucitrap eht fo stnemele

fo kcolb a setacolla teppins edoc gniwollof eht ,elpmaxe roF .yarra na N tni ,neht dna ,s yarra gnisu hguorht 0 seulav eht htiw ti sllif ,noitaton N- :1

;)N * )tni( foezis( collam = A* tni

;i tni

)++i ;N < i ;0 = i( rof

;i = ]i[A

detneserper era C ni hcihw ,sgnirts htiw gnilaed rof lufesu yrev si aedi sihT fo syarra yb rahc detanimret ,s a htiw '\ '0 ,snoitcnuf fo noitaralced eht ni sretniop sa desserpxe syawla ylraen era syarra esehT .retcarahc

stnemelpmi taht noitcnuf a si ereh ,elpmaxe roF .noitaton yarra s'C aiv dessecca tub nelrts :

hc( nelrts tni )s* ra

{

;i tni

' =! ]i[s ;0 = i( rof \ )++i ;'0

;

)i( nruter

}

syarrA lanoisnemiditluM gnitacollA yllacimanyD .2.2 llac ot drawrofthgiarts s'ti taht nees ev'eW collam na etalumis nac hcihw yromem fo kcolb a etacolla ot

nur ta kcip ot teg ew hcihw ezis a htiw tub ,yarra - etalumis ot gniht fo tros emas eht od ew naC .emitam woh wonk t'nod ew fI .sretniop ot sretniop gnisu pu dne ll'ew tub ,nac eW ?syarra lanoisnemiditlum yn

ew sa ediw snmuloc ynam sa( wor hcae rof yromem etacolla ylraelc ll'ew ,evah lliw yarra eht snmuloc gnillac yb )ekil collam kcart peek ew lliw woH .retniop a yb detneserper eb erofereht lliw wor hcae dna ,

fo ynam ,lla retfa ,era erehT ?sretniop esoht fo fo yarra na etalumis ot tnaw ew oS .wor hcae rof eno ,meht fo( yarra taht etalumis ot evah ll'ew os ,rehtie ,eb lliw ereht swor ynam woh wonk t'nod ew tub ,sretniop

.retniop a ot retniop a eb lliw siht dna ,retniop rehtona htiw )sretniop

lli tseb si sihT :elpmaxe na htiw detartsu

>h.bildts< edulcni#

;yarra** tni

;))* tni(foezis * sworn(collam = yarra

Page 19: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 91

)LLUN == yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

)++i ;sworn < i ;0 = i(rof

{

* snmulocn(collam = ]i[yarra ;))tni(foezis

)LLUN == ]i[yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

}

yarra retniop a si - ot - retniop - ot - tni .wor hcae rof eno ,sretniop fo kcolb a ot stniop ti ,level tsrif eht ta :tsrif tahT - tsrif eht si retniop level sah ti ;etacolla ew eno swor n hguone gib tnemele hcae htiw ,stnemele

retniop a dloh ot - ot - tni ro , * tni lla( sretniop eht ni llif neht ew ,ti etacolla yllufsseccus ew fI . swor n fo morf deniatbo osla( retniop a htiw )meht collam ot ) snmuloc n fo rebmun ni t wor taht rof egarots eht ,s

:raelc gnihtyreve ekam dluohs erutcip a ,esnes gnikam etiuq t'nsi siht fI .yarra eht fo

yarra fo noitatneserper :1giF

eno eht rof sa tsuj( nac ew ,siht enod ev'ew ecnO - yarra esu )esac lanoisnemid - ruo ssecca ot xatnys ekilis etirw ew fI .yarra lanoisnemiditlum detalum

]j[]i[yarra

eht rof gniksa er'ew i yb ot detniop retniop ht' yarra eht rof neht dna , j renni taht yb ot detniop tni ht'vlovni ,yrenihcam tnereffid yletelpmoc emos hguohtla :tluser ecin ytterp a si sihT( .retniop slevel owt gni

yllacimanyd ,detalumis eht ,senecs eht dniheb no gniog si ,gnicnerefered retniop fo - owt detacolla -emas eht htiw .e.i ,syarra fo yarra na erew ti fi sa tsuj dessecca eb llits nac ''yarra`` lanoisnemid fo riap

.).stpircsbus detekcarb gorp a fI ti ,syarra lanoisnemiditlum detacolla yllacimanyd ,detalumis sesu mar

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 91

)LLUN == yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

)++i ;sworn < i ;0 = i(rof

{

* snmulocn(collam = ]i[yarra ;))tni(foezis

)LLUN == ]i[yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

}

yarra retniop a si - ot - retniop - ot - tni .wor hcae rof eno ,sretniop fo kcolb a ot stniop ti ,level tsrif eht ta :tsrif tahT - tsrif eht si retniop level sah ti ;etacolla ew eno swor n hguone gib tnemele hcae htiw ,stnemele

retniop a dloh ot - ot - tni ro , * tni lla( sretniop eht ni llif neht ew ,ti etacolla yllufsseccus ew fI . swor n fo morf deniatbo osla( retniop a htiw )meht collam ot ) snmuloc n fo rebmun ni t wor taht rof egarots eht ,s

:raelc gnihtyreve ekam dluohs erutcip a ,esnes gnikam etiuq t'nsi siht fI .yarra eht fo

yarra fo noitatneserper :1giF

eno eht rof sa tsuj( nac ew ,siht enod ev'ew ecnO - yarra esu )esac lanoisnemid - ruo ssecca ot xatnys ekilis etirw ew fI .yarra lanoisnemiditlum detalum

]j[]i[yarra

eht rof gniksa er'ew i yb ot detniop retniop ht' yarra eht rof neht dna , j renni taht yb ot detniop tni ht'vlovni ,yrenihcam tnereffid yletelpmoc emos hguohtla :tluser ecin ytterp a si sihT( .retniop slevel owt gni

yllacimanyd ,detalumis eht ,senecs eht dniheb no gniog si ,gnicnerefered retniop fo - owt detacolla -emas eht htiw .e.i ,syarra fo yarra na erew ti fi sa tsuj dessecca eb llits nac ''yarra`` lanoisnemid fo riap

.).stpircsbus detekcarb gorp a fI ti ,syarra lanoisnemiditlum detacolla yllacimanyd ,detalumis sesu mar

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 91

)LLUN == yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

)++i ;sworn < i ;0 = i(rof

{

* snmulocn(collam = ]i[yarra ;))tni(foezis

)LLUN == ]i[yarra(fi

{

yromem fo tuo" ,rredts(ftnirpf \ ;)"n

nruter ro tixe

}

}

yarra retniop a si - ot - retniop - ot - tni .wor hcae rof eno ,sretniop fo kcolb a ot stniop ti ,level tsrif eht ta :tsrif tahT - tsrif eht si retniop level sah ti ;etacolla ew eno swor n hguone gib tnemele hcae htiw ,stnemele

retniop a dloh ot - ot - tni ro , * tni lla( sretniop eht ni llif neht ew ,ti etacolla yllufsseccus ew fI . swor n fo morf deniatbo osla( retniop a htiw )meht collam ot ) snmuloc n fo rebmun ni t wor taht rof egarots eht ,s

:raelc gnihtyreve ekam dluohs erutcip a ,esnes gnikam etiuq t'nsi siht fI .yarra eht fo

yarra fo noitatneserper :1giF

eno eht rof sa tsuj( nac ew ,siht enod ev'ew ecnO - yarra esu )esac lanoisnemid - ruo ssecca ot xatnys ekilis etirw ew fI .yarra lanoisnemiditlum detalum

]j[]i[yarra

eht rof gniksa er'ew i yb ot detniop retniop ht' yarra eht rof neht dna , j renni taht yb ot detniop tni ht'vlovni ,yrenihcam tnereffid yletelpmoc emos hguohtla :tluser ecin ytterp a si sihT( .retniop slevel owt gni

yllacimanyd ,detalumis eht ,senecs eht dniheb no gniog si ,gnicnerefered retniop fo - owt detacolla -emas eht htiw .e.i ,syarra fo yarra na erew ti fi sa tsuj dessecca eb llits nac ''yarra`` lanoisnemid fo riap

.).stpircsbus detekcarb gorp a fI ti ,syarra lanoisnemiditlum detacolla yllacimanyd ,detalumis sesu mar

Page 20: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 02

hcihw snoitcnuf ''suoenegoreteh`` etirw ot elbissop semoceb t'nod woh )emit elipmoc ta( wonk ot evahrav fo ''syarra`` no etarepo nac noitcnuf eno ,sdrow rehto nI .era ''syarra`` eht gib .sepahs dna sezis suoi

ekil gnihtemos kool lliw noitcnuf ehT

)snmulocn tni ,sworn tni ,yarra** tni(2cnuf

{

}

retniop a tpecca seod noitcnuf sihT - ot - retniop - ot - tni htiw ti gnillac eb ylno ll'ew taht noitpmussa eht no ,um detacolla yllacimanyd ,detalumis ekil syarra no noitcnuf siht llac ton tsum eW( .syarra lanoisnemiditl

yarra lanoisnemiditlum ''eurt`` eht 2a snoisnemid eht stpecca osla noitcnuf ehT .)snoitces suoiverp eht fomuloc`` dna ''swor`` ynam woh wonk lliw ti taht os ,sretemarap sa syarra eht fo nac ti taht os ,era ereht ''sn

retniop a tuo sorez hcihw noitcnuf a si ereH .yltcerroc meht revo etareti - ot - owt ,retniop - lanoisnemid :''yarra``

)snmulocn tni ,sworn tni ,yarra** tni(tiorez diov

{

;j ,i tni

)++i ;sworn < i ;0 = i(rof

{

j ;0 = j(rof )++j ;snmulocn <

;0 = ]j[]i[yarra

}

}

ew '',syarra`` lanoisnemiditlum detacolla yllacimanyd eseht fo eno eerf ot emit semoc ti nehw ,yllaniFpot eht gnieerf tsuJ( .detacolla ev'ew taht yromem fo sknuhc eht fo hcae eerf ot rebmemer tsum - level

,retniop yarra eht lla ,did ew fi ;ti tuc t'ndluow , dnoces - dna ,deerf ton tub tsol eb dluow sretniop level :ekil kool thgim edoc eht tahw s'ereH ).yromem etsaw dluow

)++i ;sworn < i ;0 = i(rof

;)]i[yarra(eerf

;)yarra(eerf

snoinU dna serutcurtS .3.2 :

erutcurtS :

resu a si erutcurts A - ylbaredisnoc atad fo epyt wen a enifed ot ytiliba eht evah uoY .epyt atad denifed ,selbairav erom ro eno fo noitcelloc a si erutcurts A .gnisu neeb evah ew sepyt eht naht xelpmoc erom

ednu rehtegot depuorg ,sepyt tnereffid fo ylbissop era serutcurtS .gnildnah tneinevnoc rof eman elgnis a r pleh serutcurtS .lacsaP ylbaton ,segaugnal emos ni ”sdrocer“ dellac ezinagro ,atad detacilpmoc

Page 21: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 12

tinu a sa detaert eb ot selbairav detaler fo puorg a timrep yeht esuaceb ,smargorp egral ni ylralucitrap.seititne etarapes sa fo daetsni

A .meht troppus ot serutcurts atad xelpmoc seriuqer noitacilppa s’yadoT noitcelloc a si erutcurts

fo stnemele detaler .epyt tnereffid a ot sgnoleb tnemele erehw a si erutcurts a ta kool ot yaw rehtonA etalpmet – .nrettap a resu lacihparg elpmaxe roF lacipyt serutcurts seriuqer wodniw a ni dnuof ecafretni

serutcurts fo esu eht rof elpmaxe ,eman elif lacigol ekil atad yek eht sdloh hcihw elbat elif eht eb dluocelif eht fo noitacol a si C ni elbat elif ehT .no os dna csid no erutcurts denifed epyt - .ELIF tnemele hcaE

ynam a sah dleif A .dleif sa dellac osla si erutcurts a fo lamron a fo taht ot ralimis citsiretcarahc .elbairav nA yarra ylthgils era erutcurts a dna stnemele suoenegomoh fo noitcelloc a sah remrof ehT .tnereffid tub

a sah rettal eht nwohs si C ni erutcurts a rof tamrof lareneg ehT .stnemele suoenegoreteh fo noitcelloc

s tcurt ;reifitnedi_elbairav }tsil_dleif{

tcurts eman_tcurts

{

;1emandleif 1epyt

;2emandleif 2epyt

.

.

.

;Nemandleif Nepyt

;}

tcurts rav eman_tcurts ;selbai

` tnereffid os ,yrav nac dna etercnoc ton si nwohs tamrof evoba ehT

.nwohs sa si noitaralced erutcurts fo sruovalf

tcurts

{

.…

;refitnedi_elbairav }

elpmaxE

tcurts ;piuqe_bom

{

;IEMI tni gnol

;]01[etad_ler rahc

Page 22: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 22

;]01[ledom rahc

;]51[dnarb rahc

;}

htiw dedargpu eb nac elpmaxe evoba ehT .fedepyt eht etartsulli ot margorp A

.noitces suoiverp eht ni nwohs si erutcurts eht fo gnikrow

tcurts fedepyt ;piuqe_bom

{

;IEMI tni gnol

;]01[etad_ler rahc

;]01[ledom rahc

;]51[dnarb rahc

;tnuoc tni

;1m BOM ;BOM }

s tcurt gat

{

.……

;}

tcurts ;srefitnedi_elbairav gat

tcurts fedepyt

{

..……

;REIFITINEDI_EPYT }

;srefitnedi_elbairav REIFITNEDI_EPYT

erutcurts a gnisseccA

eht ssecca ot desu eb nac erutcurts a fo eman gat a ro elbairav erutcurts A eht htiw erutcurts a fo srebmem ’.‘ rotarepo laiceps a fo pleh – rebmem sa dellac osla aedi eht ssecca oT elpmaxe suoiverp ruo nI . rotarepo

elibom eht fo IEMI eht fo siht ekil enod si piuqe_bom erutcurts eht ni tnempiuqe erutcurts eht ecniSb nac elbairav OI eht llA elbairav lamron a sa detaert e eht rof doog sdloh elbairav lamron a rof snoitcnuf

ehT .thgils htiw osla elbairav erutcurts woleb nevig si IEMI eht ot tupni eht daer ot tnemetats fnacs

;)IEMI.1m&,”d%“( fnacs

Page 23: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 32

era noitarepo tnemerced dna tnemercnI siht selbairav lamron eht sa emas .osla xiferp dna xiftsop sedulcnieht naht ecnedecerp erom sah rotarepo rebmeM detouq elpmaxe ni esoppus yaS .tnemerced ro tnemercni

fo tnuoc tnaw ew reilrae neht tneduts

tnuoc.1m++ ;++tnuoc.1m

snoinU

yrev era snoinU rof doog sdloh raf os dessucsid revetahw ,serutcurts ot ralimis od yhw neht osla snoinusti fo ezis eht no sdneped snoinu fo eziS ?snoinu deen ew tsegral htiw rebmem ro epyt tsegral fo rebmem

ni nos ton si siht tub ,ezis fo esac .serutcurts

elpmaxE noinu a 1cb

{

tni ;a

taolf ;b

rahc ;c

;}

yna ta eroferehT .epyt tsegral si taolf sa setyb4 si 1cba noinu eht fo ezis ehT ssecca nac ew emit fo tniopot sdeen siht dna noinu eht fo rebmem eno ylno remmargorp yb derebmemer .

atad erutcurts gnisU issa evah ew taht woN nI .meht htiw erised ew gnihtyna od nac ew ,selbairav elpmis xis eht ot seulav deng

sa tsixe od yllaer yeht fi ees ot seulav eht tuo tnirp ylpmis lliw ew ,elpmis elpmaxe tsrif siht peek ot redrouoy ,stnemetats ftnirp eht tcepsni ylluferac uoy fI .dengissa tuoba laiceps gnihton si ereht taht ees lliw

ew hcihw yb eman dilav ylno eht si taht esuaceb deificeps si elbairav hcae fo eman dnuopmoc ehT .meht ot redro ni rehtegot atad gnipuorg fo dohtem lufesu yrev a era serutcurtS .selbairav eseht ot refer nac

ekam .dnatsrednu dna etirw ot reisae margorp a

4.2 slaimonyloP. :

I n scitamehtam a , laimonylop keerG morf( ylop nitaL laveidem dna "ynam" , muimonib " , laimonib " ]1[ ]2[ ]3[ na si ) noisserpxe fo etinif morf detcurtsnoc htgnel selbairav sa nwonk osla( setanimretedni dna )

stnatsnoc fo snoitarepo eht ylno gnisu , noitidda , noitcartbus , noitacilpitlum non dna , - evitagen regetni stnenopxe ,elpmaxe roF . x2 4 − x tub ,laimonylop a si 7 + x2 /4 − x 7 + x 2/3 dnoces sti esuaceb ,ton si mret

elbairav eht yb noisivid sevlovni x a ton si taht tnenopxe na sniatnoc mret driht sti esuaceb dna )x/4( eb nac taht seititnauq rof ,evitcejda na sa desu eb osla nac "laimonylop" mret ehT .)2/3( rebmun elohw

sa ,retemarap emos fo laimonylop a sa desserpxe " ni emit laimonylop ni desu si hcihw " lanoitatupmoct ytixelpmoc yroeh .

ot desu era yeht ,elpmaxe roF .ecneics dna scitamehtam fo saera fo yteirav ediw a ni raeppa slaimonyloP yratnemele morf ,smelborp fo egnar ediw a edocne hcihw ,snoitauqe laimonylop mrof smelborp drow ot

ni raeppa hcihw ,snoitcnuf laimonylop enifed ot desu era yeht ;secneics eht ni smelborp detacilpmoc cisab morf gnignar sgnittes yrtsimehc dna scisyhp ot scimonoce dna ecneics laicos ni desu era yeht ;

suluclac dna sisylana laciremun tcnuf rehto etamixorppa ot slaimonylop ,scitamehtam decnavda nI .snoi tcurtsnoc ot desu era sgnir laimonylop ni tpecnoc lartnec a , arbegla tcartsba dna yrtemoeg ciarbegla .

Page 24: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 42

.deilpitlum ro detcartbus ,dedda ylno era taht smret fo pu edam si laimonylop A

:siht ekil skool laimonylop A

laimonylop a fo elpmaxe smret 3 sah eno siht

:2 giF

laimonyloP mrof semoc ylop - dna )"ynam" gninaem( - laimon syas ti os ... )"mret" gninaem esac siht ni("smret ynam"

:evah nac laimonylop A

stnatsnoc ekil( 3 , - 02 ro , ½ )

selbairav ekil( x dna y)

stnenopxe y ni 2 eht ekil( 2 ylno tub ) ... ,3 ,2 ,1 ,0 cte

eb nac tahT :gnisu denibmoc

+ ,noitidda

- dna ,noitcartbus

× M noitacilpitlu

!noisivid ton tub ...

!htiw krow ot ysae era yeht os ,elpmis slaimonylop speek selur esohT

?toN ro laimonyloP

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 42

.deilpitlum ro detcartbus ,dedda ylno era taht smret fo pu edam si laimonylop A

:siht ekil skool laimonylop A

laimonylop a fo elpmaxe smret 3 sah eno siht

:2 giF

laimonyloP mrof semoc ylop - dna )"ynam" gninaem( - laimon syas ti os ... )"mret" gninaem esac siht ni("smret ynam"

:evah nac laimonylop A

stnatsnoc ekil( 3 , - 02 ro , ½ )

selbairav ekil( x dna y)

stnenopxe y ni 2 eht ekil( 2 ylno tub ) ... ,3 ,2 ,1 ,0 cte

eb nac tahT :gnisu denibmoc

+ ,noitidda

- dna ,noitcartbus

× M noitacilpitlu

!noisivid ton tub ...

!htiw krow ot ysae era yeht os ,elpmis slaimonylop speek selur esohT

?toN ro laimonyloP

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 42

.deilpitlum ro detcartbus ,dedda ylno era taht smret fo pu edam si laimonylop A

:siht ekil skool laimonylop A

laimonylop a fo elpmaxe smret 3 sah eno siht

:2 giF

laimonyloP mrof semoc ylop - dna )"ynam" gninaem( - laimon syas ti os ... )"mret" gninaem esac siht ni("smret ynam"

:evah nac laimonylop A

stnatsnoc ekil( 3 , - 02 ro , ½ )

selbairav ekil( x dna y)

stnenopxe y ni 2 eht ekil( 2 ylno tub ) ... ,3 ,2 ,1 ,0 cte

eb nac tahT :gnisu denibmoc

+ ,noitidda

- dna ,noitcartbus

× M noitacilpitlu

!noisivid ton tub ...

!htiw krow ot ysae era yeht os ,elpmis slaimonylop speek selur esohT

?toN ro laimonyloP

Page 25: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 52

:3 giF

esehT era :slaimonylop

x3

x - 2

- y6 2 - (7/9 x)

yx3 + zyx3 2 z - zx1.0 - 5.0 + y002

v215 5 + w99 5

1

.)tnatsnoc a eb ot sneppah tsuj hcihw mret eno sah ti ,laimonylop a si "1" neve ,seY(

era eseht dnA ton slaimonylop

)2+x(/2 dewolla ton si gnidivid esuaceb ,ton si

x/1 ton si

yx3 -2 " si tnenopxe eht esuaceb ,ton si - opxe( "2 )...,2,1,0 eb ylno nac stnen

x√ ees( "½" si tnenopxe eht esuaceb ,ton si stnenopxe lanoitcarf )

tuB eseht era :dewolla

2/x dewolla si osla si ti esuaceb , x)½( .0 ro ,½ si tnatsnoc eht( )5

osla 8/x3 )573.0 ro ,8/3 si tnatsnoc eht( nosaer emas eht rof

2√ )cte...2414.1 =( tnatsnoc a si ti esuaceb ,dewolla si

laimonirT ,laimoniB ,laimonoM

:smret 3 ro 2 ,1 htiw slaimonylop rof seman laiceps era erehT

Page 26: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 62

cyc knihT ?seman eht rebmemer uoy od woH !sel

,)smret 5( laimonitniuq dna )smret 4( laimonirdauq osla si erehT(:4 giF )desu netfo ton era seman esoht tub

5.2 esrapS . secirtaM :

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps A ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam woh" enifed ot spleh noitinifed sihT .stnemele

erutcurts eht tahw no sdneped ti taht si rewsna roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

.nosnikliW fo esnes eht ni esraps ton si xirtam :txeN scihparG decnavdA :pU snoitatupmoc xirtam esrapS :suoiverP snoitatupmoc xirtam esrapS

xirtam esraps a gnitaerC :

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerc :elpmaxe roF .tamrof esraps ni derots xirtam

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

0 1 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 62

cyc knihT ?seman eht rebmemer uoy od woH !sel

,)smret 5( laimonitniuq dna )smret 4( laimonirdauq osla si erehT(:4 giF )desu netfo ton era seman esoht tub

5.2 esrapS . secirtaM :

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps A ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam woh" enifed ot spleh noitinifed sihT .stnemele

erutcurts eht tahw no sdneped ti taht si rewsna roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

.nosnikliW fo esnes eht ni esraps ton si xirtam :txeN scihparG decnavdA :pU snoitatupmoc xirtam esrapS :suoiverP snoitatupmoc xirtam esrapS

xirtam esraps a gnitaerC :

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerc :elpmaxe roF .tamrof esraps ni derots xirtam

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

0 1 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 62

cyc knihT ?seman eht rebmemer uoy od woH !sel

,)smret 5( laimonitniuq dna )smret 4( laimonirdauq osla si erehT(:4 giF )desu netfo ton era seman esoht tub

5.2 esrapS . secirtaM :

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps A ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam woh" enifed ot spleh noitinifed sihT .stnemele

erutcurts eht tahw no sdneped ti taht si rewsna roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

.nosnikliW fo esnes eht ni esraps ton si xirtam :txeN scihparG decnavdA :pU snoitatupmoc xirtam esrapS :suoiverP snoitatupmoc xirtam esrapS

xirtam esraps a gnitaerC :

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerc :elpmaxe roF .tamrof esraps ni derots xirtam

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

0 1 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

Page 27: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 72

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - oc ehT .tamrof esned ni ti etaerc tsrif ot gnimusnoc dnamm )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

oreznon wef a htiw xirtam a ,si taht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehTanogaid eht htiw detaerc eb nac xirtam a hcuS .sl sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 72

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - oc ehT .tamrof esned ni ti etaerc tsrif ot gnimusnoc dnamm )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

oreznon wef a htiw xirtam a ,si taht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehTanogaid eht htiw detaerc eb nac xirtam a hcuS .sl sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 72

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - oc ehT .tamrof esned ni ti etaerc tsrif ot gnimusnoc dnamm )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

oreznon wef a htiw xirtam a ,si taht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehTanogaid eht htiw detaerc eb nac xirtam a hcuS .sl sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

Page 28: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 82

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 61 0 0

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 46 0 0 61 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - gaid niam eht( 3 dna ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lano - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot ,slanogaid eht ,esruoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaid

us rof mottob eht ta og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidb :xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 61 46 0 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocnogaid eht fo secidni eht sdeen :sla

[ = d >> - ,3 - ;]3,1,0,1

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 82

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 61 0 0

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 46 0 0 61 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - gaid niam eht( 3 dna ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lano - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot ,slanogaid eht ,esruoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaid

us rof mottob eht ta og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidb :xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 61 46 0 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocnogaid eht fo secidni eht sdeen :sla

[ = d >> - ,3 - ;]3,1,0,1

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 82

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 61 0 0

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 46 0 0 61 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - gaid niam eht( 3 dna ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lano - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot ,slanogaid eht ,esruoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaid

us rof mottob eht ta og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidb :xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 61 46 0 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocnogaid eht fo secidni eht sdeen :sla

[ = d >> - ,3 - ;]3,1,0,1

Page 29: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 92

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

ni ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahrePisu ,tamrof esned dnammoc eht gn eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps .

si dnammoc lufesu rehtonA yps roF .xirtam a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe - xirtam lanogaid A t yb deyalpsid eb nac erugiF ees ;dnammoc gniwollof eh 6 :

)A(yps >>

:5 giF xirtam a fo nrettap ytisraps ehT

syarra lanoisnemiditluM fo noitatneserpeR .6.2 owt a roF - secidni htiw tnemele eht ,yarra lanoisnemid i, j sserdda evah dluow B + c · i + d · j eht erehw ,

stneiciffeoc c dna d eht era wor dna stnemercni sserdda nmuloc .ylevitcepser , a ni ,yllareneg eroM k- secidni htiw tnemele na fo sserdda eht ,yarra lanoisnemid i ,1 i ,2 … , ki si

B + c · 1 i + 1 c · 2 i + 2 … + kc · ki ylno seriuqer alumrof sihT k dna snoitacilpitlum k− .yromem ni tif nac taht yarra yna rof ,snoitidda 1

op dexif a si tneiciffeoc yna fi ,revoeroM .gnitfihs tib yb decalper eb nac noitacilpitlum eht ,2 fo rew stneiciffeoc ehT kc tcnitsid a fo sserdda eht ot spam elput xedni dilav yreve taht os nesohc eb tsum

neht ,0 si xedni yreve rof eulav lagel muminim eht fI .tnemele B nemele eht fo sserdda eht si esohw teno eht ni sA .orez lla era secidni - eht gnignahc yb degnahc eb yam secidni tnemele eht ,esac lanoisnemid

sserdda esab B owt a fi ,suhT . - ,02 ot 1 dna 01 ot 1 morf dexedni snmuloc dna swor sah yarra lanoisnemid gnicalper neht ,ylevitcepser B yb B + c 1 - − 3 c dna 9 hguorht 0 morf derebmuner eb ot meht esuac lliw 1

yficeps )77 NARTROF ekil( segaugnal emos ,erutaef siht fo egatnavda gnikaT .ylevitcepser ,32 hguorht 4ekil( segaugnal rehto elihw ;noitidart lacitamehtam ni sa ,1 ta nigeb secidni yarra taht lacsaP ,09 nartroF

.xedni hcae rof eulav muminim eht esoohc resu eht tel )loglA dna

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 92

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

ni ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahrePisu ,tamrof esned dnammoc eht gn eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps .

si dnammoc lufesu rehtonA yps roF .xirtam a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe - xirtam lanogaid A t yb deyalpsid eb nac erugiF ees ;dnammoc gniwollof eh 6 :

)A(yps >>

:5 giF xirtam a fo nrettap ytisraps ehT

syarra lanoisnemiditluM fo noitatneserpeR .6.2 owt a roF - secidni htiw tnemele eht ,yarra lanoisnemid i, j sserdda evah dluow B + c · i + d · j eht erehw ,

stneiciffeoc c dna d eht era wor dna stnemercni sserdda nmuloc .ylevitcepser , a ni ,yllareneg eroM k- secidni htiw tnemele na fo sserdda eht ,yarra lanoisnemid i ,1 i ,2 … , ki si

B + c · 1 i + 1 c · 2 i + 2 … + kc · ki ylno seriuqer alumrof sihT k dna snoitacilpitlum k− .yromem ni tif nac taht yarra yna rof ,snoitidda 1

op dexif a si tneiciffeoc yna fi ,revoeroM .gnitfihs tib yb decalper eb nac noitacilpitlum eht ,2 fo rew stneiciffeoc ehT kc tcnitsid a fo sserdda eht ot spam elput xedni dilav yreve taht os nesohc eb tsum

neht ,0 si xedni yreve rof eulav lagel muminim eht fI .tnemele B nemele eht fo sserdda eht si esohw teno eht ni sA .orez lla era secidni - eht gnignahc yb degnahc eb yam secidni tnemele eht ,esac lanoisnemid

sserdda esab B owt a fi ,suhT . - ,02 ot 1 dna 01 ot 1 morf dexedni snmuloc dna swor sah yarra lanoisnemid gnicalper neht ,ylevitcepser B yb B + c 1 - − 3 c dna 9 hguorht 0 morf derebmuner eb ot meht esuac lliw 1

yficeps )77 NARTROF ekil( segaugnal emos ,erutaef siht fo egatnavda gnikaT .ylevitcepser ,32 hguorht 4ekil( segaugnal rehto elihw ;noitidart lacitamehtam ni sa ,1 ta nigeb secidni yarra taht lacsaP ,09 nartroF

.xedni hcae rof eulav muminim eht esoohc resu eht tel )loglA dna

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 92

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

ni ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahrePisu ,tamrof esned dnammoc eht gn eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps .

si dnammoc lufesu rehtonA yps roF .xirtam a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe - xirtam lanogaid A t yb deyalpsid eb nac erugiF ees ;dnammoc gniwollof eh 6 :

)A(yps >>

:5 giF xirtam a fo nrettap ytisraps ehT

syarra lanoisnemiditluM fo noitatneserpeR .6.2 owt a roF - secidni htiw tnemele eht ,yarra lanoisnemid i, j sserdda evah dluow B + c · i + d · j eht erehw ,

stneiciffeoc c dna d eht era wor dna stnemercni sserdda nmuloc .ylevitcepser , a ni ,yllareneg eroM k- secidni htiw tnemele na fo sserdda eht ,yarra lanoisnemid i ,1 i ,2 … , ki si

B + c · 1 i + 1 c · 2 i + 2 … + kc · ki ylno seriuqer alumrof sihT k dna snoitacilpitlum k− .yromem ni tif nac taht yarra yna rof ,snoitidda 1

op dexif a si tneiciffeoc yna fi ,revoeroM .gnitfihs tib yb decalper eb nac noitacilpitlum eht ,2 fo rew stneiciffeoc ehT kc tcnitsid a fo sserdda eht ot spam elput xedni dilav yreve taht os nesohc eb tsum

neht ,0 si xedni yreve rof eulav lagel muminim eht fI .tnemele B nemele eht fo sserdda eht si esohw teno eht ni sA .orez lla era secidni - eht gnignahc yb degnahc eb yam secidni tnemele eht ,esac lanoisnemid

sserdda esab B owt a fi ,suhT . - ,02 ot 1 dna 01 ot 1 morf dexedni snmuloc dna swor sah yarra lanoisnemid gnicalper neht ,ylevitcepser B yb B + c 1 - − 3 c dna 9 hguorht 0 morf derebmuner eb ot meht esuac lliw 1

yficeps )77 NARTROF ekil( segaugnal emos ,erutaef siht fo egatnavda gnikaT .ylevitcepser ,32 hguorht 4ekil( segaugnal rehto elihw ;noitidart lacitamehtam ni sa ,1 ta nigeb secidni yarra taht lacsaP ,09 nartroF

.xedni hcae rof eulav muminim eht esoohc resu eht tel )loglA dna

Page 30: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 03

stuoyal tcapmoC taht ,revewoH .yromem fo aera suougitnoc a ypucco stnemele eht taht os nesohc era stneiciffeoc eht netfO

syawla era syarra fi nevE .yrassecen ton si gnicils yarra emos ,stnemele suougitnoc htiw detaercnon etaerc yam snoitarepo - bus suougitnoc - .meht morf syarra

owt a rof stuoyal tcapmoc citametsys owt era erehT - xirtam eht redisnoc ,elpmaxe roF .yarra lanoisnemid

wor eht nI - detpoda( tuoyal redro rojam era wor hcae fo stnemele eht ,)syarra deralced yllacitats rof C yb:snoitisop evitucesnoc ni derots

nmuloC nI - ni evitucesnoc era nmuloc hcae fo stnemele eht ,)nartroF yb desu yllanoitidart( redro rojam:yromem

or" ,secidni erom ro eerht htiw syarra roF stnemele owt yna snoitisop evitucesnoc ni stup "redro rojam w eht ni eno yb ylno reffid selput xedni esohw tsal tcepser htiw suogolana si "redro rojam nmuloC" .xedni

eht ot tsrif ra na gninnacs ,yromem lautriv ro ehcac rossecorp esu hcihw smetsys nI .xedni hcum si yar .derettacs ylesraps naht rehtar ,yromem ni snoitisop evitucesnoc ni derots era stnemele evisseccus fi retsaf remmargorp A .redro elbatciderp a ni meht nacs lliw syarra lanoisnemiditlum esu taht smhtirogla ynaM

yam )relipmoc detacitsihpos a ro( wor neewteb esoohc ot noitamrofni siht esu - nmuloc ro - tuoyal rojam tcudorp eht gnitupmoc nehw ,elpmaxe roF .yarra hcae rof A· B evah ot tseb eb dluow ti ,secirtam owt fo A

wor ni derots - dna ,redro rojam B nmuloc ni - .redro rojam

itluM fo noitatneserpeR ehT :syarrA lanoisnemid N- M[A ,noisnemid 0 M[] 2 M[. . .] n-1] – i[A yrtne yna fo sserddA 0 i[] 1 i[...] n-1]

:gniziser yarrA eb ot stnemele wolla ton od yltneuqesnoc dna emit noitacolla ta dexif si taht ezis a evah syarra citatS

arra dlo eht fo stnetnoc eht gniypoc dna yarra wen a gnitacolla yb ,revewoH .devomer ro detresni ti ,ti ot y

110,

{ ,i+esab

1

11

1-n

0=jj

1

12

1432

1321

1210

n

njkj

j

n

nn

n

n

n

anja

erehwa

iMi

MMMiMMMiMMMiesab

Page 31: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 13

a tnemelpmi ylevitceffe ot elbissop si cimanyd ro elbaworg siht fI .yarra cimanyd ees ;yarra na fo noisrev.emit tnatsnoc dezitroma ylno eriuqer yarra eht fo dne eht ta snoitresni ,yltneuqerfni enod si noitarepo

on od serutcurts atad yarra emoS eht fo stnemele fo rebmun eht fo tnuoc a erots od tub ,egarots etacollaer t dexif a htiw yarra cimanyd a yarra eht sekam ylevitceffe sihT .ezis ro tnuoc eht dellac ,esu ni yarra

;yticapac ro ezis mumixam sgnirts lacsaP .siht fo selpmaxe era noN - mrof raenil salu

non"( detacilpmoc eroM - owt tcapmoc a roF .desu yllanoisacco era salumrof )"raenil - lanoisnemid.2 eerged fo laimonylop a si alumrof gnisserdda eht ,ecnatsni rof ,yarra ralugnairt

ycneiciffE htoB erots dna tceles tnatsnoc )esac tsrow citsinimreted( ekat (O( raenil ekat syarrA .emit n eht ni ecaps ))

stnemele fo rebmun n ezis tnemele htiw yarra na nI .dloh yeht taht k enil ehcac a htiw enihcam a no dna fo yarra na hguorht gnitareti ,setyb B fo ezis n (gniliec fo muminim eht seriuqer stnemele kn ehcac )B/

ssim /B fo rotcaf a ylhguor si sihT .snoitacol yromem suougitnoc ypucco stnemele sti esuaceb ,se k retteb ssecca ot dedeen sessim ehcac fo rebmun eht naht n a sA .snoitacol yromem modnar ta stnemele

f ylbaeciton si yarra na revo noitareti laitneuqes ,ecneuqesnoc ynam revo noitareti naht ecitcarp ni retsa seod siht( ecnerefer fo ytilacol dellac ytreporp a ,serutcurts atad rehto ton a gnisu taht ,revewoh naem

retsaf neve eb ton lliw ,yarra )lacol( emas eht nihtiw hsah laivirt ro hsah tcefrep - ni elbaveihca dnasnoc .)emit tnat

yromeM - rep on htiw serutcurts atad tcapmoc era syarra ,esiw - rep a eb yam erehT .daehrevo tnemele - yarraegaugnal si siht tub ,sdnuob xedni erots ot .g.e ,daehrevo - stnemele taht neppah osla nac tI .tnedneped

eriuqer yarra na ni derots ssel romem esuaceb ,selbairav laudividni ni derots stnemele emas eht naht y dellac netfo era syarra hcus ;drow elgnis a ni derots eb nac stnemele yarra lareves dekcap nA .syarra

le elgnis a stneserper tib yreve erehw ,yarra tib eht si esac )desu ylnommoc tub( emertxe .tneme

dexedni rof emit raenil ekat tub elddim eht ni noitresni dna lavomer emit tnatsnoc wolla stsil dekniL a ot evitanretla nA .raenil llits si tub ,syarra naht esrow yllacipyt si esu yromem riehT .ssecca

no a esu ot si erutcurts yarra lanoisnemiditlum e- eno fo syarra ot secnerefer fo yarra lanoisnemid .ssel noisnemid

eno ,srotcev ot sretniop fo rotcev a eb dluow erutcurts evitanretla siht ,ralucitrap ni ,snoisnemid owt roF

wor ni tnemele na suhT .wor hcae rof i nmuloc dna j yarra na fo A ecca eb dluow gnixedni elbuod yb dess(A[i [] j swolla erutcurts evitanretla sihT .)noitaton lacipyt ni ] deggar ro deggaj wor hcae erehw ,syarra

ezis tnereffid a evah yam — fo seulav eht no sdneped xedni hcae fo egnar dilav eht erehw ,lareneg ni ,ro.secidni gnidecerp lla a yb ti gnicalper )tnemercni sserdda nmuloc eht yb( noitacilpitlum eno sevas osla tI

,)sserdda wor eht gnihctef( ssecca yromem artxe eno dna )sretniop wor fo rotcev eht xedni ot( tfihs tib.serutcetihcra emos ni elihwhtrow eb yam hcihw

.7.2 UQ DEDNEMMOCER SNOITSE erutcurts fo sesu 2 yna noitneM ?noinu na morf reffid erutcurts a seod woH .1

2 elgnis eht nialpxE . - .yarra lanoisnemid

3 2 fo noitazilaitini & noitaralced eht nialpxE . - .yarra D

4 .enod xirtam a fo gnisopsnart woH .

5 fo noitatneserper eht nialpxE . .yarra lanoisnemiditlum

6 .noitatneserper xirtam esraps eht nialpxE .

Page 32: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 23

TINU – 3 : SEUEUQ DNA SKCATS

:skcatS.1.3 A kcats dna detresni eb yam smeti wen hcihw otni smeti fo noitcelloc deredro na si hcihw morf smeti

eht dellac ,dne eno ta deteled eb yam pot fo sa tcejbo gnignahc yltnatsnoc ,cimanyd a si kcats A .kcats eht sa kcats eht fo dne elgnis sah tI .smeti fo noiteled dna noitresni eht rof sedivorp kcats eht fo noitinifed eht

.ecalp sekat stnemele eht fo noiteled dna noitresni htob erehw ,kcats eht fo pot detresni tnemele tsal ehTdeteled tnemele tsrif eht si kcats eht otni - .)OFIL( tsil tuo tsrif ni tsal dna snoitresni lareves retfA

.niaga emarf emas eht evah ot elbissop si ti ,snoiteled

snoitarepO evitimirP

si ti ,kcats a ot dedda si meti na nehW hsup o de si ti ,devomer si meti na nehW .kcats eht otn pop morf dep.kcats eht

kcats a neviG s meti na dna , i noitarepo eht gnimrofrep , )i,s(hsup na sdda meti i kcats fo pot eht ot .s

;)H ,s(hsup

;)I ,s(hsup

;)J ,s(hsup

noitarepO )s(pop fi ,si tahT .tnemele pot eht sevomer )s(pop=i eht neht , ot dengissa si tnemele devomer .i

;)s(pop

si kcats a ,kcats a ot stnemele sdda hcihw noitarepo hsup eht fo esuaceB a dellac semitemos nwodhsup.tsil yllautpecnoC rebmun eht no timil reppu on si ereht , tpek eb yam taht smeti fo .kcats a ni kcats a fI

kcats gnitluser eht ,deppop si kcats eht dna meti elgnis a sniatnoc eht dellac si dna smeti on sniatnoc ytpme .kcats hsuP ot deilppa eb tonnac noitarepo poP .kcats yna ot elbacilppa si noitarepo ytpme eht

s ,os fI .kcat wolfrednu noitarepo naelooB A .sneppah )s(ytpme snruter , .ytpme si kcats fi EURT.ytpme ton si kcats fi ,ESLAF esiwrehtO

C ni skcats gnitneserpeR

ediced tsum ew ,kcats a sesu taht noitulos melborp a gnimmargorp erofeB cats eht tneserper ot woh ni k agnimmargorp noitcelloc deredro na si tI .egaugnal deredro na sa YARRA evah ew ,C nI .smeti fo

kcats a tuB .smeti fo noitcelloc yarra na ni stnemele fo rebmun ehT .sgniht tnereffid owt era yarra na dnasi ezis esohw tcejbo cimanyd a si kcats A .dexif yarra na ,oS .gnignahc yltnatsnoc si egral deralced eb nac

si C ni kcats A .kcats eht fo ezis mumixam eht rof hguone :stcejbo owt gniniatnoc erutcurts a sa deralced

.kcats eht fo stnemele eht dloh ot yarra nA •

eht fo noitisop eht etacidni ot regetni nA • pot kcats tnerruc .yarra eht nihtiw

001 EZISKCATS enifed#

{ kcats tcurts

;pot tni

Page 33: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 33

;]EZISKCATS[smeti tni

;}

kcats ehT s yb deralced eb yam

;s kcats tcurts

eb yam smeti kcats ehT tni on sniatnoc kcats ytpme ehT .cte ,rahc ,taolf , erofereht nac dna stnemele eb yb detacidni pot = - eht ot S kcats a ezilaitini oT .1 etucexe yllaitini yam ew ,etats ytpme

pot.s = - .1

,noitidnoc ytpme kcats enimreted oT

=pot.s( fi - )1

;ytpme kcats

esle

;ytpme ton si kcats

swollof sa deredisnoc eb yam )s(ytpme ehT :

tcurts(ytpme tni )sp* kcats

{

sp(fi - ==pot> - )1

;)EURT(nruter

esle

;)ESLAF(nruter

}

noitatnemelpmi fo tes eht gnitagerggA - ,llams otni stops elbuort tnedneped na si stinu elbaifitnedi ylisaeerom margorp a gnikam fo dohtem tnatropmi pecnoc sihT .elbaifidom dna elbadnatsrednu sa nwonk si t

noitaziraludom ni , wol otni detalosi era snoitcnuf laudividni hcihw - seitreporp esohw seludom level erawol esehT .elbaifirev ylisae - level seludom xelpmoc erom yb desu eb neht nac evah ton od hcihw ,senituor

ated eht htiw sevlesmeht nrecnoc ot eht fo sli wol - level xelpmoc ehT .noitcnuf rieht htiw ylno tub seludomyam senituor rehgih llits yb seludom sa deweiv eb neht sevlesmeht - meht esu taht senituor level

.sliated lanretni rieht fo yltnednepedni

• noitarepo pop gnitnemelpmI

tpme si kcats eht fI eht evomeR .noitucexe tlah dna egassem gninraw a tnirp ,y .kcats eht morf tnemele potmargorp gnillac eht ot tnemele siht nruteR

)sp* kcats tcurts(pop tni

{

Page 34: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 43

{))sp(ytpme(fi

;)”wolfrednu kcats”,”%“(ftnirp

;)1(tixe

}

sp(nruter - sp[smeti> - pot> -- ;)]

}

kcatS .2.3 syarrA cimanyD gnisU s :

:elpmaxe roF

fedepyT tcurts

{ rahc * rts ; } sdrow ; niam )( { x sdrow [ 001 ;] atad sa yarra eht fo ezis eht esaercni cimanyd ot tnaw I ,siht esu ot tnaw ton od I //

.nisemoc }

ereh elpmaxe roF meht evas dna elif txt. a morf sdrow laudividni daer i hcihw ni yarra gniwollof eht si:yarra eht ni drow yb drow

:edoC

rahc sdrow [ 0001 [] 51 ;]

naht erom ton fo esirpmoc yam drow hcae dna evas nac yarra eht sdrow fo rebmun eht senifed 0001 ereHsretcarahc 51 . fo rebmun eht rof yromem eht etacolla yllacimanyd dluohs margorp taht taht tnaw I woN

eht taht tnaw I woN .0001 taht retaerg sdrow niatnoc yam elif txt. a ,elpmaxe roF .stnuoc ti sdrowocca yromem eht etacolla dna sdrow fo rebmun eht tnuoc dluohs margorp .ylgnidr a esu tonnac ew ecniS

siht ni em pleh esaelP .cigol ym tnemelpmi ot woh ta knalb yletelpmoc ma I ,]0001[ fo ecalp ni elbairav.drager

seueuQ .3.3 :

a sah eueuq ehT .rellet knab a rof gnitiaw elpoep fo enil a ekil si eueuq A tnorf a dna raer .

nehW eueuq eht ot snoitiddA .raer eht dna tnorf eht :sdne tcnitsid owt tuoba klat ew seueuq fo klat ew ta snioj ti ,noitucexe rof dettimbus si boj a fi ,oS .tnorf eht morf edam era snoiteleD .raer eht ta ecalp ekat

norf eht ta boj ehT .eueuq boj eht fo raer eht detucexe eb ot eno txen eht si eueuq eht fo t

.raer eht ta eueuq eht retne tsum elpoep weN • hsup , na dellac yllausu si ti hguohtla eueuqne .noitarepo

Page 35: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 53

.tnorf eht morf semoc syawla ti ,eueuq eht morf nekat si meti na nehW • pop ellac yllausu si ti hguohtla , d a eueuqed .noitarepo

eueuQ si tahW ?

.raer dna tnorf sa sdne owt sah taht stnemele fo noitcelloc deredrO •

dne tnorf morf eteleD •

dne raer morf tresnI •

eueuq siht ,elpmaxe roF .ereh nwohs sa ,yarra na htiw detnemelpmi eb nac eueuq A • getni eht sniatnoc sre.)raer eht ta( 6 dna 8 ,)tnorf eht ta( 4

snoitarepO eueuQ

wolfrevO eueuQ •

eueuq eht otni tnemele eht fo noitresnI •

wolfrednu eueuQ •

eueuq eht morf tnemele eht fo noiteleD •

eueuq eht fo yalpsiD •

{ eueuQ tcurts

;]ezis[ euq tni

;tnorf tni

;raer tni

} ;Q

:elpmaxE

>h.oidts< edulcni#

>h.bildts< edulcni#

>h.oinoc< edulcni#

5 ezis enifed#

{ eueuq tcurts

;]ezis[euq tni

;raer ,tnorf tni

;Q }

Page 36: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 63

:elpmaxE

>h.oidts< edulcni#

>h.bildts< edulcni#

>h.oinoc< edulcni#

5 ezis enifed#

{ eueuq tcurts

;]ezis[euq tni

tni ;raer ,tnorf

;Q }

{) ( llufQ tni

ezis => raer.Q( fi - )1

;1 nruter

esle

;0 nruter

}

{) (ytpmeQ tni

== tnorf.Q(( fi - ))raer.Q > tnorf.Q(||)1

;1 nruter

esle

;0 nruter

}

{ )meti tni( tresni tni

== tnorf.Q( fi - )1

;++tnorf.Q

;meti = ]raer.Q++[euq.Q

raer.Q nruter ;

}

{ )( eteled tnI

;meti tnI

Page 37: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 73

;]tnorf.Q[euq.Q = metI

;++tnorf.Q

;tnorf.Q nruteR

}

{ )( yalpsid dioV

;I tnI

)++i;raer.Q=<i;tnorf.Q=i( roF

;)]i[euq.Q,”d% “(ftnirP

}

{ )diov( niam dioV

;meti ,eciohc tnI

= tnorf.Q - = raeR.Q ;1 - ;1

{ od

ruoy retnE“(ftnirP ;)”yalpsiD:3 ,D:2 ,I:1 : eciohc

;)eciohc& ,”d%“(fnacS

{)eciohc(hctiwS

;)”tresnI tnnaC“(ftnirp ))(llufQ(fi :1 esaC

;kaerb ;)meti(tresni ;)meti,”d%“(fnacs esle

;)”wolfrednU“(ftnirp ))(ytpmeQ(fi :2 esaC

;kaerb ;)(eteled esle

}

}

}

4.3 D gnisU seueuQ ralucriC . syarrA cimany :

eueuQ ralucriC

i ,yarra ralucric a fo dne eht tsap sevom tnemele na nehW • .gninnigeb eht ot dnuora sparw t

yarra eht gnidrager yb deniatbo si noitatneserper eueuq tneiciffe erom A Q 1( n: tI .ralucric sa ) sa yarra eht eralced ot tneinevnoc erom semoceb won Q :0( n - )1 . = raer nehW n - txen eht ,1

ta deretne si tnemele Q tnorf ,erofeb sa snoitnevnoc emas eht gnisU .eerf si tops taht esac ni )0(

Page 38: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 83

,niagA .eueuq eht ni tnemele tsrif eht morf esiwkcolcretnuoc noitisop eno tniop syawla lliw tnorf= raer evah ew yllaitinI .ytpme si eueuq eht fi ylno dna fi tnorf = raer = 1. setartsulli 4.3 erugiF

eueuq ralucric a rof snoitarugifnoc elbissop eht fo emos stnemele ruof eht gniniatnoc J1-J htiw 4n redro nI .ylthgils smhtirogla ETELED dna DDA eht segnahc ytiralucric fo noitpmussa ehT .4 >

evom ot yrassecen eb lliw ti ,tnemele na dda ot raer ,.e.i ,esiwkcolc noitisop eno

fi raer = n - 1 neht raer 0 esle raer raer .1 +

stnemele n fo eueuq ralucriC : erugiF

tsuj si siht ,sredniamer setupmoc hcihw rotarepo oludom eht gnisU ( raer raer )1 + dom .n evom ot yrassecen eb lliw ti ,ylralimiS tnorf .edam si noiteled a emit hcae esiwkcolc noitisop eno

yb dehsilpmocca eb nac siht ,noitarepo oludom eht gnisu ,niagA tnorf ( tnorf + )l dom .n nA a ni tuo deirrac eb won nac noiteled dna noitidda taht setacidni smhtirogla eht fo noitanimaxe

t fo tnuoma dexif ro emi O .)1(

.g.e

))4(eueuqnE retfa( 3697OOOO4 _ 3697OOOOO •

.4 ot 3 morf sevom xedni raer ,)4(eueuqnE retfA •

:noitidnoC lluF eueuQ

lluF si eueuQ )ezis%)1+raer( == tnorf(fi

:tresni ew od erehW •

;meti=]raer[eueuq ;ezis%)1 + raer( = raer

f : noiteled retfA ;ezis%)1+tnorf( = tnor

eueuQ ralucriC a fo elpmaxE

0 si tnorf erehw 06 dna ,04 ,02 stnemele eerht sah 5 si hcihw fo ezis eht ,Q ralucriC A •

:snoitarepo eseht fo hcae retfa fo seulav eht era tahW .2 si raer dna

,06 ,04 ,02 = Q - , - tnorf – raer ,]0[02 – ]2[06

:05 meti tresnI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 83

,niagA .eueuq eht ni tnemele tsrif eht morf esiwkcolcretnuoc noitisop eno tniop syawla lliw tnorf= raer evah ew yllaitinI .ytpme si eueuq eht fi ylno dna fi tnorf = raer = 1. setartsulli 4.3 erugiF

eueuq ralucric a rof snoitarugifnoc elbissop eht fo emos stnemele ruof eht gniniatnoc J1-J htiw 4n redro nI .ylthgils smhtirogla ETELED dna DDA eht segnahc ytiralucric fo noitpmussa ehT .4 >

evom ot yrassecen eb lliw ti ,tnemele na dda ot raer ,.e.i ,esiwkcolc noitisop eno

fi raer = n - 1 neht raer 0 esle raer raer .1 +

stnemele n fo eueuq ralucriC : erugiF

tsuj si siht ,sredniamer setupmoc hcihw rotarepo oludom eht gnisU ( raer raer )1 + dom .n evom ot yrassecen eb lliw ti ,ylralimiS tnorf .edam si noiteled a emit hcae esiwkcolc noitisop eno

yb dehsilpmocca eb nac siht ,noitarepo oludom eht gnisu ,niagA tnorf ( tnorf + )l dom .n nA a ni tuo deirrac eb won nac noiteled dna noitidda taht setacidni smhtirogla eht fo noitanimaxe

t fo tnuoma dexif ro emi O .)1(

.g.e

))4(eueuqnE retfa( 3697OOOO4 _ 3697OOOOO •

.4 ot 3 morf sevom xedni raer ,)4(eueuqnE retfA •

:noitidnoC lluF eueuQ

lluF si eueuQ )ezis%)1+raer( == tnorf(fi

:tresni ew od erehW •

;meti=]raer[eueuq ;ezis%)1 + raer( = raer

f : noiteled retfA ;ezis%)1+tnorf( = tnor

eueuQ ralucriC a fo elpmaxE

0 si tnorf erehw 06 dna ,04 ,02 stnemele eerht sah 5 si hcihw fo ezis eht ,Q ralucriC A •

:snoitarepo eseht fo hcae retfa fo seulav eht era tahW .2 si raer dna

,06 ,04 ,02 = Q - , - tnorf – raer ,]0[02 – ]2[06

:05 meti tresnI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 83

,niagA .eueuq eht ni tnemele tsrif eht morf esiwkcolcretnuoc noitisop eno tniop syawla lliw tnorf= raer evah ew yllaitinI .ytpme si eueuq eht fi ylno dna fi tnorf = raer = 1. setartsulli 4.3 erugiF

eueuq ralucric a rof snoitarugifnoc elbissop eht fo emos stnemele ruof eht gniniatnoc J1-J htiw 4n redro nI .ylthgils smhtirogla ETELED dna DDA eht segnahc ytiralucric fo noitpmussa ehT .4 >

evom ot yrassecen eb lliw ti ,tnemele na dda ot raer ,.e.i ,esiwkcolc noitisop eno

fi raer = n - 1 neht raer 0 esle raer raer .1 +

stnemele n fo eueuq ralucriC : erugiF

tsuj si siht ,sredniamer setupmoc hcihw rotarepo oludom eht gnisU ( raer raer )1 + dom .n evom ot yrassecen eb lliw ti ,ylralimiS tnorf .edam si noiteled a emit hcae esiwkcolc noitisop eno

yb dehsilpmocca eb nac siht ,noitarepo oludom eht gnisu ,niagA tnorf ( tnorf + )l dom .n nA a ni tuo deirrac eb won nac noiteled dna noitidda taht setacidni smhtirogla eht fo noitanimaxe

t fo tnuoma dexif ro emi O .)1(

.g.e

))4(eueuqnE retfa( 3697OOOO4 _ 3697OOOOO •

.4 ot 3 morf sevom xedni raer ,)4(eueuqnE retfA •

:noitidnoC lluF eueuQ

lluF si eueuQ )ezis%)1+raer( == tnorf(fi

:tresni ew od erehW •

;meti=]raer[eueuq ;ezis%)1 + raer( = raer

f : noiteled retfA ;ezis%)1+tnorf( = tnor

eueuQ ralucriC a fo elpmaxE

0 si tnorf erehw 06 dna ,04 ,02 stnemele eerht sah 5 si hcihw fo ezis eht ,Q ralucriC A •

:snoitarepo eseht fo hcae retfa fo seulav eht era tahW .2 si raer dna

,06 ,04 ,02 = Q - , - tnorf – raer ,]0[02 – ]2[06

:05 meti tresnI

Page 39: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 93

,05 ,06 ,04 ,02 = Q - tnorf - raer ,]0[02 - ]3[05

:01 meti tresnI

tnorf 01 ,05 ,06 ,04 ,02 = Q - raer ,]0[02 - ]4[01

tnorf 01 ,05 ,06 ,04 ,02 = Q - raer ,]0[02 - ]4[01

03 tresnI

.wolfrevo ecneh ,0 = 5%)1+4( = ezis%)1 + raer( = raeR

meti na eteleD

1=5%)1+0( = ezis%)1+tnorf( = tnorf ,02 eteled

meti na eteleD

2=5&)1+1( = ezis%)1+tnorf( = tnorf ,04 eteled

0 noitisop ta 03 tresnI

0 = 5%)1+4( = ezis%)1 + raer( = raeR

1 noitisop ta 08 tresnI ylralimiS

5.3 xiftsop a gnitaulavE :snoisserpxE fo noitaulavE .e noisserpx :

yeht ,segaugnal gnimmargorp level rehgih fo aedi eht deviecnoc stsitneics retupmoc gnireenoip nehW enihcam etareneg ot woh fo noitseuq eht saw tseggib eht fo enO .seldruh lacinhcet ynam htiw decaf erew

ylreporp dluow hcihw snoitcurtsni egaugnal tnemngissa xelpmoc A .noisserpxe citemhtira yna etaulave sa hcus tnemetats

X A/B ** C + D * E - A * C )1.3(

llits ti ,sesehtnerap fo esu lluf a yb yas ,denifed yleuqinu erew ti fi neve dna ;sgninaem lareves evah thgimtareneg ot ksat elbadimrof a demees eht yletanutroF .ecneuqes noitcurtsni elbanosaer dna tcerroc a e

relipmoc fo tcepsa siht taht elpmis os si ti ,revoeroM .elpmis dna tnagele htob si yadot evah ew noitulos .seussi ronim erom eht fo eno yllaer si gnitirw

sdnarepo fo pu edam si noisserpxe nA :sdnarepo evif sah evoba noisserpxe ehT .sretimiled dna srotarepo ,A,B,C,D dna , E ro eman elbairav lagel yna eb nac sdnarepo ,selbairav rettel eno lla era eseht hguohT .

tnetsisnoc eb tsum ekat selbairav taht seulav eht noisserpxe yna nI .egaugnal gnimmargorp ruo ni tnatsnoced era snoitarepo esehT .meht no demrofrep snoitarepo eht htiw tsom nI .srotarepo eht yb debircs

fo sdnik tnereffid eht ot dnopserroc hcihw srotarepo fo sdnik lareves era ereht segaugnal gnimmargorp dna ,edivid ,semit ,sunim ,sulp :srotarepo citemhtira cisab eht era ereht ,tsriF .dloh nac elbairav a atad

oitaitnenopxe ,+( n - dna sunim yranu ,sulp yranu edulcni srotarepo citemhtira rehtO .)**,/,*, liec ,dom dna ,roolf dnoces A .srotarepo denifederp naht rehtar senituorbus yrarbil eb semitemos yam eerht rettal ehT .

ed yllausu era esehT . :srotarepo lanoitaler eht era ssalc nac yeht tub ,sdnarepo citemhtira rof krow ot denif ni 'GOD' sedecerp ti ecnis 'GOD' naht ssel si 'TAC'( .atad gnirts retcarahc rof krow ylisae sa tsuj owt eht fo eno si srotarepo lanoitaler sniatnoc hcihw noisserpxe na fo tluser ehT ).redro lacitebahpla

Page 40: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 04

c :stnatsno eurt ro eslaf egroeG naicitamehtam eht retfa deman ,naelooB dellac si noisserpxe lla hcuS . .cigol cilobmys fo rehtaf eht ,elooB

eht redro tahw ni ediced ot si noisserpxe na fo gninaem eht gnidnatsrednu htiw melborp tsrif ehTirrac era snoitarepo roF .redro na hcus enifed yleuqinu tsum egaugnal yreve taht snaem sihT .tuo de

fi ,ecnatsni A ,4 = B = C ,2 = D = E tnaw thgim ew 1.3 .qe ni neht ,3 = X eulav eht dengissa eb ot

)3 * 3( + )2 ** 2(/4 - )2 * 4( 9 + )4/4( = - 8

.2 = xe na redisnoc won su teL eht etaulave ot deksa era ew taht esoppuS .elpma :noisserpxe xiftsop gniwollof

+ 3 2 6 - + 3 $ 2 * + / 2 8 3

ktsdnpo eulaV 2dnpO 1dnpO bmyS

6 6

2,6 2

3,2,6 3

5,6 5 3 2 +

- 1 1 5 6

3,1 1 5 6 3

8,3,1 1 5 6 8

2,8,3,1 1 5 6 2

4,3,1 4 2 8 /

8

7,1 7 4 3 +

7 1 * 7 7

2,7 7 7 1 2

94 94 2 7 $

3,94 94 2 7 3

25 3 94 + 25

na hcaer ew nehW .kcats a otno ti hsup ew ,dnarepo na daer ew emit hcaE eb lliw sdnarepo sti ,rotarepopop neht nac eW .kcats eht no stnemele owt pot eht detacidni eht mrofrep ,stnemele owt eseht noitarepo

tluser eht hsup dna ,meht no txen eht fo dnarepo na sa esu rof elbaliava eb lliw ti taht os kcats eht no.rotarepo tupni eht ni raeppa taht sdnarepo fo rebmun eht si kcats eht fo ezis mumixam ehT .noisserpxe

ts eht fo ezis lautca eht ,yllausu tuB ,mumixam naht ssel si dedeen kca owt pot eht spop rotarepo sa.sdnarepo

Page 41: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 14

noisserpxe xiftsop etaulave ot margorP

evah ew ,snoitarepo ytpme ,pop ,hsup htiw gnolA tigidsi ,lave dna repo .snoitarepo

lave – mhtirogla noitaulave eht

)][rpxe rahc(lave elbuod

{

tni ;noitisop ,c

;eulav ,2dnpo ,1dnpo elbuod

;ktsdnpo kcats tcurts

=pot.ktsdnpo - ;1

’=!)]noitisop[ rpxe=c (; 0=noitisop( rof \ )++noitisop ;’0

)tigidsi( fi

c( )elbuod( ,ktsdnpo&( hsup - ;))’0‘

{esle

;)ktsdnpo&( pop=2dnpo

9

;)ktsdnpo&( pop=1dnpo

1dnpo ,c(repo=eulav ;)2dnpo,

;)eulav .ktsdnpo&( hsup

}

;))ktsdnpo&(pop(nruter

}

tigidsi – dnarepo na si tnemugra sti ton ro rehtehw enimreted ot ,lave yb dellac

)bmys rahc(tigidsi tni

{

;)’9’=<bmys && ’0’=>bmys(nruter

}

repo – na ot gnidnopserroc noitarepo eht tnemelpmi ot lobmys rotarepo

)2po elbuod ,1po elbuod ,bmys tni(repo elbuod

{

Page 42: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 24

{)bmys( hctiws

;)2po+1po( nruter : ’+‘ esac

‘ esac - 1po( nruter : ‘ - ;)2po

;)2po*1po( nruter : ’*‘ esac

;)2po/1po(nruter : ’/‘ esac

;)2po ,1po( wop( nruter : ’$‘ esac

elli”,”s%“( ftnirp :tluafed ;)”noitarepo lag

;)1(tixe

}

}

xiftsop ot xifni morf noisserpxe na gnitrevnoC

:noisserpxe xifni eerf sesehtnerap nevig eht redisnoC

C * B + A

ktspo gnirts xiftsoP bmyS

A A 1

+ A + 2

+ BA B 3

* + BA * 4

* + CBA C 5

+ * CBA 6

+ * CBA 7

nevig eht redisnoC :noisserpxe xifni sesehtnerap

C*)B+A(

ktspO gnirts xiftsoP bmyS

( ( 1

( A A 2

+ ( A + 3

+ ( BA B 4

+BA ) 5

Page 43: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 34

* +BA * 6

* C+BA C 7

*C+BA 8

xiftsop ot xifni morf noisserpxe na trevnoc ot margorP

idda fo esu ekam osla ew ,tsetdnapop ,ytpme ,hsup ,pop htiw gnolA lanoit ,sa hcus snoitcnuf ,dnareposi.xiftsop ,dcrp

dnareposi – esiwrehto ESLAF dna dnarepo na si tnemugra sti fi EURT snruter

dcrp – tsrif eht fi EURT snruter dna stnemugra sa slobmys rotarepo owt stpecca eht revo ecnedecerp sah ot sraeppa ti nehw dnoces xifni na ni dnoces eht fo tfel eht esiwrehto ESLAF dna gnirts

xiftsop – gnirts xiftsop eht stnirp

seueuQ dna skcatS elpitluM .6.3 :

eht ni eueuq elgnis a ro kcats elgnis a fo noitatneserper eht htiw ylno denrecnoc neeb evah ew won ot pU tahW .snoitatneserper atad laitneuqes tneiciffe nees evah ew sesac owt eseht roF .retupmoc a fo yromem

rof dedeen si noitatneserper atad a nehw sneppah timil niaga ecno su teL ?seueuq dna skcats lareves yarra na otni stcejbo atad eseht fo sgnippam laitneuqes ot ,sevlesruo V :1( m ot skcats 2 ylno evah ew fI .)

esu nac eW .elpmis si noitulos eht neht .tneserper V dna 1 kcats ni tnemele tsom mottob eht rof )1( V(m ) sdrawot worg nac 1 kcatS .2 kcats ni tnemele gnidnopserroc eht rof V(m sdrawot 2 kcats dna ) V si tI .)1(

2 naht erom nehw emas eht od ew naC .ecaps elbaliava eht lla yltneiciffe ezilitu ot elbissop eroferehtsi rewsna ehT ?detneserper eb ot era skcats stniop dexif owt ylno sah yarra lanoisnemid eno a esuaceb ,on

V dna )1( V(m owt naht erom nehW .tnemele tsommottob sti rof tniop dexif a seriuqer kcats hcae dna ) yas ,skcats n m elbaliava eht tuo edivid yllaitini nac ew ,yllaitneuqes detneserper eb ot era , yrome V :1( m )

otni n eht fo hcae ot stnemges eseht fo eno etacolla dna stnemges n fo noisivid laitini sihT .skcats V :1( m ) nI .nwonk era sezis eht fi skcats suoirav eht fo sezis detcepxe ot noitroporp ni enod eb yam stnemges otni

tamrofni hcus fo ecnesba eht ,noi V :1( m kcats hcae roF .stnemges lauqe otni dedivid eb yam ) i llahs ew esu B(i ni noitisop eht naht ssel eno noitisop a tneserper ot ) V .kcats taht fo tnemele tsommottob eht rof

T(i 1 ,) i n kcats fo tnemele tsompot eht ot tniop lliw i noitidnoc yradnuob eht esu llahs eW . B(i = ) T(i ffi ) eht i eht worg ew fI .ytpme si kcats ht' i eht naht sexedni yromem rewol ni kcats ht' i htiw neht ,ts'1 +

evah ew stnemges laitini lauqe ylhguor

B (i = ) T (i = ) m/n (i - i 1 ,)1 n )2.3(

laitini eht sa fo seulav B(i dna ) T(i kcatS .)9.3 erugif ees( ,) i 1 , i n morf worg nac B(i ot pu 1 + ) B(i )1 + eht htiw pu sehctac ti erofeb i ot smhtirogla eht dna noissucsid eht rof htob tneinevnoc si tI .kcats ts'1 +

enifed B(n = )1 + m dna dda eht emehcs siht gnisU . :emoceb smhtirogla eteled

erudecorp DDA ( X,i ) tnemele dda// X eht ot i i 1 ,kcats ht' n //

fi T(i = ) B(i )1 + llac neht KCATS - LLUF (i) T(i ) T(i 1 + ) V(T(i )) X dda// X eht ot i //kcats ht'

dne DDA erudecorp ETELED ( X,i )

Page 44: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 44

kcats fo tnemele tsompot eteled// i // fi T(i = ) B(i ) llac neht KCATS - YTPME (i) X V(T(i ))

T(i ) T(i ) - 1 dne ETELED

si yllaer sihT .skcats 2 ro 1 ylno fo esac eht ni sa elpmis a eb ot raeppa eteled dna dda ot smhtirogla ehT lla taht ylpmi ton seod DDA mhtirogla ni noitidnoc LLUF_KCATS eht ecnis esac eht ton m fo snoitacol

V unu fo tol a eb yam ereht ,tcaf nI .esu ni era skcats neewteb ecaps des j dna j 1 rof 1 + j n dna j i ehT .( LLUF_KCATS erudecorp i ni ecaps eerf yna si ereht rehtehw enimreted erofereht dluohs ) V tfihs dna

eht ot elbaliava ecaps eerf siht fo emos ekam ot sa os dnuora skcats i .kcats ht'

getarts lareveS ygetarts eno ssucsid llahs eW .LLUF_KCATS mhtirogla fo ngised eht rof elbissop era sei si LLUF_KCATS mhtirogla fo evitcejbo yramirp ehT .sesicrexe eht ni srehto emos ta kool dna txet eht ni

mos si ereht sa gnol os skcats ot stnemele fo gnidda eht timrep ot ni ecaps eerf e V eetnaraug ot yaw enO . :senil gniwollof eht gnola LLUF_KCATS ngised ot si siht

tsael eht enimreted )a j < i ,j n skcats neewteb ecaps eerf si ereht taht hcus j dna j ,.e.i ,1 + T(j < ) B(j .)1 + a hcus si ereht fI j skcats evom neht , i 1 + , i ,... ,2 + j gnitaert( thgir eht ot noitisop eno V dna tsomtfel sa )1(

V(m skcats neewteb ecaps a gnitaerc ybereht ,)tsomthgir sa ) i dna i .1 +

on si ereht fi )b j kcats fo tfel eht ot kool neht ,)a ni sa i tsegral eht dniF . j 1 taht hcus j < i si ereht dna skcats neewteb ecaps j dna j ,.e.i ,1 + T(j < ) B(j a hcus si ereht fI .)1 + j skcats evom neht , j ,1 + j ,... ,2 + i

skcats neewteb ecaps eerf a gnitaerc tfel ecaps eno i dna i .1 +

on si ereht fi )c j o )a fo snoitidnoc eht rehtie gniyfsitas lla neht ,)b r m fo secaps V si ereht dna dezilitu era.ecaps eerf on

eht rof noitatneserper siht fo ecnamrofrep esac tsrow eht taht raelc eb dluohs tI n eht htiw rehtegot skcatssac tsrow eht ni ,tcaf nI .roop rehtar eb dluow LLUF_KCATS rof ygetarts evoba e O(m eb yam emit )

sevlesruo timil ton od ew fi taht ees llahs ew retpahc txen eht nI .)sesicrexe ees( noitresni hcae rof dedeen rof noitatneserper atad a niatbo nac ew neht ,syarra otni stcejbo atad fo sgnippam laitneuqes ot m skcats

etteb hcum a sah taht .ereh debircsed noitatneserper eht naht ecnamrofrep esac tsrow r

.7.3 SNOITSEUQ DEDNEMMOCER : snoisserpxe xiftsop gniwollof eht etaulavE .3=C ,2=B ,1=A emussA .1 C+BA )a - $C+AB -

ABC*+CBA )b - *+

2 xiftsop ot noisserpxe xifni gniwollof eht trevnoC . : A(( - )F+E($)D*))C+B(

snoisserpxe gnitneserper fo syaw tnereffid eht nialpxE .3

snoitaton xiftsop & xifni gnisu fo segatnavda eht etatS .4

snoisrevnoc xiftsop ot xifni gnirud dewollof eb ot selur eht etatS .5

ot xifni gnirud dewollof eb ot selur eht etatS .6 snoisrevnoc xiferp

syarra naht stsil deknil gnisu skcats gnitneserper fo segatnavda eht noitneM .7

Page 45: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 54

TINU – 4 : STSIL DEKNIL 1.4 ylgniS . sniahC dna stsil dekniL :

,noitatnemelpmi gniruD .seueuq dna skcats fo skcabward eht tuoba ssucsid su teL wolfrevo oN .srucco ro kcats fo smeti eht ,noitatneserper laitneuqes a nI .seueuq dna skcats erom rof stsixe noitulos elpmis

era eueuq ylticilpmi .egarots fo redro laitneuqes eht yb deredro

era eueuq ro kcats fo smeti eht fI ylticilpxe c meti hcae ,si taht ,deredro sserdda eht flesti nihtiw deniatno sa nwonk erutcurts atad wen a nehT .meti txen eht fo raenil .tsil deknil a dellac si tsil eht ni meti hcaE

edon na ,sdleif owt sniatnoc dna dleif noitamrofni a dna dleif sserdda txen sdloh dleif noitamrofni ehT .autca eht hcuS .tsil eht ni edon txen eht fo sserdda eht sniatnoc dleif sserdda txen ehT .tsil eht no tnemele l

a sa nwonk si ,edon ralucitrap a ssecca ot desu si hcihw ,sserdda na .retniop ehT retniop llun ot desu si sedon on htiw tsil ehT .tsil a fo dne eht langis – tsil ytpme ro .tsil llun smhtirogla ni desu snoitaton ehT

fI:era p ,edon a ot retniop a si )p(edon yb ot detniop edon eht ot srefer )p(ofnI .p noitamrofni eht otsrefer .edon taht fo )p(txen refer fI .noitrop sserdda txen ot s )p(txen ,llunton si ))p(txen(ofni eht ot srefer

swollof taht edon eht fo noitrop noitamrofni )p(edon .tsil ehtni

A tsil deknil a si )"tsil deknil ylgnis" ,ylraelc erom ro( erutcurts atad fo ecneuqes a fo stsisnoc taht sedon a sniatnoc hcihw fo hcae ecnerefer a ,.e.i( knil .ecneuqes eht ni edon txen eht ot )

edon txen eht ot knil a dna eulav regetni na :sdleif owt niatnoc sedon esohw tsil deknil A

mmoc tsom dna tselpmis eht gnoma era stsil dekniL tnemelpmi ot desu eb nac yehT .serutcurts atad no nommoc rehto lareves serutcurts atad tcartsba gnidulcni , skcats , seueuq , syarra evitaicossa , dna cilobmys

snoisserpxe tsil a gnisu tuohtiw yltcerid serutcurts atad rehto eht tnemelpmi ot nommocnu ton si ti hguoht ,.noitatnemelpmi fo sisab eht sa

lanoitnevnoc a revo tsil deknil a fo tifeneb lapicnirp ehT yarra dedda eb ylisae nac stnemele tsil eht taht siht fo noitazinagroer ro noitacollaer tuohtiw devomer ro ton deen smeti atad eht esuaceb erutcurts eritne e

yna ta sedon fo lavomer dna noitresni wolla stsil dekniL .ksid no ro yromem ni ylsuougitnoc derots eb knil eht ot suoiverp knil eht fi snoitarepo fo rebmun tnatsnoc a htiw os od nac dna ,tsil eht ni tniop gnieb

.lasrevart tsil gnirud deniatniam si devomer ro dedda

wolla ton od sevlesmeht yb stsil deknil elpmis ,dnah rehto eht nO ssecca modnar eht naht rehto atad eht ot s'edon tsrif .gnixedni tneiciffe fo mrof yna ro ,atad

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 54

TINU – 4 : STSIL DEKNIL 1.4 ylgniS . sniahC dna stsil dekniL :

,noitatnemelpmi gniruD .seueuq dna skcats fo skcabward eht tuoba ssucsid su teL wolfrevo oN .srucco ro kcats fo smeti eht ,noitatneserper laitneuqes a nI .seueuq dna skcats erom rof stsixe noitulos elpmis

era eueuq ylticilpmi .egarots fo redro laitneuqes eht yb deredro

era eueuq ro kcats fo smeti eht fI ylticilpxe c meti hcae ,si taht ,deredro sserdda eht flesti nihtiw deniatno sa nwonk erutcurts atad wen a nehT .meti txen eht fo raenil .tsil deknil a dellac si tsil eht ni meti hcaE

edon na ,sdleif owt sniatnoc dna dleif noitamrofni a dna dleif sserdda txen sdloh dleif noitamrofni ehT .autca eht hcuS .tsil eht ni edon txen eht fo sserdda eht sniatnoc dleif sserdda txen ehT .tsil eht no tnemele l

a sa nwonk si ,edon ralucitrap a ssecca ot desu si hcihw ,sserdda na .retniop ehT retniop llun ot desu si sedon on htiw tsil ehT .tsil a fo dne eht langis – tsil ytpme ro .tsil llun smhtirogla ni desu snoitaton ehT

fI:era p ,edon a ot retniop a si )p(edon yb ot detniop edon eht ot srefer )p(ofnI .p noitamrofni eht otsrefer .edon taht fo )p(txen refer fI .noitrop sserdda txen ot s )p(txen ,llunton si ))p(txen(ofni eht ot srefer

swollof taht edon eht fo noitrop noitamrofni )p(edon .tsil ehtni

A tsil deknil a si )"tsil deknil ylgnis" ,ylraelc erom ro( erutcurts atad fo ecneuqes a fo stsisnoc taht sedon a sniatnoc hcihw fo hcae ecnerefer a ,.e.i( knil .ecneuqes eht ni edon txen eht ot )

edon txen eht ot knil a dna eulav regetni na :sdleif owt niatnoc sedon esohw tsil deknil A

mmoc tsom dna tselpmis eht gnoma era stsil dekniL tnemelpmi ot desu eb nac yehT .serutcurts atad no nommoc rehto lareves serutcurts atad tcartsba gnidulcni , skcats , seueuq , syarra evitaicossa , dna cilobmys

snoisserpxe tsil a gnisu tuohtiw yltcerid serutcurts atad rehto eht tnemelpmi ot nommocnu ton si ti hguoht ,.noitatnemelpmi fo sisab eht sa

lanoitnevnoc a revo tsil deknil a fo tifeneb lapicnirp ehT yarra dedda eb ylisae nac stnemele tsil eht taht siht fo noitazinagroer ro noitacollaer tuohtiw devomer ro ton deen smeti atad eht esuaceb erutcurts eritne e

yna ta sedon fo lavomer dna noitresni wolla stsil dekniL .ksid no ro yromem ni ylsuougitnoc derots eb knil eht ot suoiverp knil eht fi snoitarepo fo rebmun tnatsnoc a htiw os od nac dna ,tsil eht ni tniop gnieb

.lasrevart tsil gnirud deniatniam si devomer ro dedda

wolla ton od sevlesmeht yb stsil deknil elpmis ,dnah rehto eht nO ssecca modnar eht naht rehto atad eht ot s'edon tsrif .gnixedni tneiciffe fo mrof yna ro ,atad

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 54

TINU – 4 : STSIL DEKNIL 1.4 ylgniS . sniahC dna stsil dekniL :

,noitatnemelpmi gniruD .seueuq dna skcats fo skcabward eht tuoba ssucsid su teL wolfrevo oN .srucco ro kcats fo smeti eht ,noitatneserper laitneuqes a nI .seueuq dna skcats erom rof stsixe noitulos elpmis

era eueuq ylticilpmi .egarots fo redro laitneuqes eht yb deredro

era eueuq ro kcats fo smeti eht fI ylticilpxe c meti hcae ,si taht ,deredro sserdda eht flesti nihtiw deniatno sa nwonk erutcurts atad wen a nehT .meti txen eht fo raenil .tsil deknil a dellac si tsil eht ni meti hcaE

edon na ,sdleif owt sniatnoc dna dleif noitamrofni a dna dleif sserdda txen sdloh dleif noitamrofni ehT .autca eht hcuS .tsil eht ni edon txen eht fo sserdda eht sniatnoc dleif sserdda txen ehT .tsil eht no tnemele l

a sa nwonk si ,edon ralucitrap a ssecca ot desu si hcihw ,sserdda na .retniop ehT retniop llun ot desu si sedon on htiw tsil ehT .tsil a fo dne eht langis – tsil ytpme ro .tsil llun smhtirogla ni desu snoitaton ehT

fI:era p ,edon a ot retniop a si )p(edon yb ot detniop edon eht ot srefer )p(ofnI .p noitamrofni eht otsrefer .edon taht fo )p(txen refer fI .noitrop sserdda txen ot s )p(txen ,llunton si ))p(txen(ofni eht ot srefer

swollof taht edon eht fo noitrop noitamrofni )p(edon .tsil ehtni

A tsil deknil a si )"tsil deknil ylgnis" ,ylraelc erom ro( erutcurts atad fo ecneuqes a fo stsisnoc taht sedon a sniatnoc hcihw fo hcae ecnerefer a ,.e.i( knil .ecneuqes eht ni edon txen eht ot )

edon txen eht ot knil a dna eulav regetni na :sdleif owt niatnoc sedon esohw tsil deknil A

mmoc tsom dna tselpmis eht gnoma era stsil dekniL tnemelpmi ot desu eb nac yehT .serutcurts atad no nommoc rehto lareves serutcurts atad tcartsba gnidulcni , skcats , seueuq , syarra evitaicossa , dna cilobmys

snoisserpxe tsil a gnisu tuohtiw yltcerid serutcurts atad rehto eht tnemelpmi ot nommocnu ton si ti hguoht ,.noitatnemelpmi fo sisab eht sa

lanoitnevnoc a revo tsil deknil a fo tifeneb lapicnirp ehT yarra dedda eb ylisae nac stnemele tsil eht taht siht fo noitazinagroer ro noitacollaer tuohtiw devomer ro ton deen smeti atad eht esuaceb erutcurts eritne e

yna ta sedon fo lavomer dna noitresni wolla stsil dekniL .ksid no ro yromem ni ylsuougitnoc derots eb knil eht ot suoiverp knil eht fi snoitarepo fo rebmun tnatsnoc a htiw os od nac dna ,tsil eht ni tniop gnieb

.lasrevart tsil gnirud deniatniam si devomer ro dedda

wolla ton od sevlesmeht yb stsil deknil elpmis ,dnah rehto eht nO ssecca modnar eht naht rehto atad eht ot s'edon tsrif .gnixedni tneiciffe fo mrof yna ro ,atad

Page 46: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 64

tsil a morf sedon gnivomer dna gnitresnI: giF

yllacimanyd dna yllacitamard yrav yam tsil a no sedon fo rebmun ehT .erutcurts atad cimanyd a si tsil Asnoc su tel ,elpmaxe roF .devomer dna detresni era stnemele sa ew dna 8 dna 3 ,5 stnemele htiw tsil a redi

,nehT .tsil taht fotnorf eht ot 6 regetni na dda ot deen

;)(edonteg=p

;6=)p(ofni

;tsil=)p(txen

;p=tsil

ot ssecorp eht fo etisoppo yltcaxe tsomla si ssecorp eht ,tsil eht morf tnemele na gnivomer rof ,ylralimiSda fo eulav eht erots dna tsil ytpmenon a fo edon tsrif eht evomeR .tsil eht fo tnorf eht ot edon a d ofni

dleif elbairav a otni x ,neht .

;tsil=p

;)p(txen=tsil

;)p(ofni=x

.2.4 ni sniahC gnitneserpeR C : stneserper edon hcae hcihw ni tsil deknil a si niahc A .tnemele eno

.txen eht ot tnemele eno morf retniop ro knil a si erehT a sah edon tsal ehT LLUN ro( 0 retniop )

sretpahc suoiverp eht ni serutcurts atad elpmis tneserper ot desu si gnippam laitneuqes a dna yarra nA

taht ytreporp eht sah noitatneserper sihT• dexif a derots era tcejbo atad eht fo sedon evisseccustrapa ecnatsid

1+jiL noitacol eht ta si1+jia neht ,jiL noitacol ta derots sijia tnemele eht fI )1(

Page 47: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 74

i eht fI )2( - )1+i( eht neht ,iL noitacol ta si eueuq a ni tnemeleht - n %1+iL noitacol ta si tnemele ht eht rofnoitatneserper ralucric

TL noitacol ta si ti htaeneb edon eht neht , TL noitacol ta si kcats a fo edon tsompot eht fI )3( - no os dna ,1

fo noiteled dna noitresni sa hcus snoitarepo ,stsil deredro rof desu si gnippam laitneuqes a nehW•ele yrartibra .evisnepxe emoceb stnem

noitatneserper deknil a nI – eht erots ew tnemele hcae htiw ,redro tcerroc eht ni stnemele tsil ssecca oTtsil eht ni tnemele txen eht fo noitacol ro sserdda – orez sah edon hcae ;sedon fo desirpmoc si tsil deknil A

sdleif atad erom ro .sdleif retniop ro knil erom ro eno dna

seueuQ dna skcatS dekniL .3.4 :

kcatS dekniL a gnihsuP

kcatS edoc rorrE :: (hsup tsnoc )meti& yrtne kcatS

/ * :tsoP ro sseccus snruter ;kcatS eht fo pot eht ot dedda si meti yrtne kcatS

nyd fi wo_revo fo edoc a snruter * .detsuahxe si yromem cima /

{

= pot wen* edoN wen meti(edoN , )edon pot ;

fi )LLUN == pot wen( nruter wo_revo ;

pot wen = edon pot ;

nruter sseccus ;

}

kcatS dekniL a gnippoP

kcatS edoc rorrE :: ) (pop

/ * :tsoP si kcatS eht fI .devomer si kcatS eht fo pot ehT snruter dohtem eht ytpme

* .sseccus snruter ti esiwrehto ;wo_rednu /

{

edon pot = pot dlo* edoN ;

fi )LLUN == edon pot( nruter wo_rednu ;

pot dlo = edon pot - txen> ;

eteled pot dlo ;

Page 48: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 84

nruter sseccus ;

}

A eueuq fo dnik ralucitrap a si noitcelloc eht dna redro ni tpek era noitcelloc eht ni seititne eht hcihw niht ot seititne fo noitidda eht era noitcelloc eht no snoitarepo )ylno ro( lapicnirp dna noitisop lanimret raer e

a eueuq eht sekam sihT .noitisop lanimret tnorf eht morf seititne fo lavomer tsriF - nI - tsriF - )OFIF( tuOerutcurts atad utcurts atad OFIF a nI . eb ot eno tsrif eht eb lliw eueuq eht ot dedda tnemele tsrif eht ,er

erew taht stnemele lla ,dedda si tnemele na ecno taht tnemeriuqer eht ot tnelaviuqe si sihT .devomere na si eueuq A .dekovni eb nac tnemele wen eht erofeb devomer eb ot evah erofeb dedda a fo elpmax

erutcurts atad raenil .

ni secivres edivorp seueuQ ecneics retupmoc , tropsnart dna , hcraeser snoitarepo seititne suoirav erehwatad sa hcus eht ,stxetnoc eseht nI .retal dessecorp eb ot dleh dna derots era stneve ro ,snosrep ,stcejbo ,

a fo noitcnuf eht smrofrep eueuq reffub .

collam<edulcni# >h. >h.oidts<edulcni#

{edontcurts ;eulavtni

;txen*edontcurts ;}

{)n*edontcurts(tinIdiov n- ;LLUN=txen> }

{)eulavtni,toor*edontcurts(eueuqnEdiov ;))edontcurts(foezis(collam)*edontcurts(=j*edontcurts

j- ;eulav=eulav> j- ;LLUN=txen>

; pmet*edontcurts ;toor=pmet pmet(elihw - )LLUN=!txen>

{ pmet=pmet - ;txen>

} pmet - ;j=txen>

d% : si deueuqnE eulaV“(ftnirp \ ;)eulav,”n

} )toor*edontcurts(eueuqeDdiov

{ toor(fi - )LLUN==txen>

{ eueuqeDottnemelEoN“(ftnirp \ ;)”n

}

Page 49: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 94

esle {

;pmet*edontcurts toor=pmet - ;txen>

toor - pmet=txen> - ;txen> p d%sideueuqeDeulaV“(ftnir \ pmet,”n - ;)eulav>

;)pmet(eerf } }

)(niamdiov {

;eueuq_elpmasedontcurts ;)eueuq_elpmas&(tinI

;)01,eueuq_elpmas&(eueuqnE ;)05,eueuq_elpmas&(eueuqnE ;)075,eueuq_elpmas&(eueuqnE ;)0175,eueuq_elpmas&(eueuqnE

;)eueuq_elpmas&(eueuqeD euqeD ;)eueuq_elpmas&(eu

;)eueuq_elpmas&(eueuqeD }

:slaimonyloP .4.4 nI scitamehtam a , laimonylop keerG morf( ylop nitaL laveidem dna "ynam" , muimonib " , laimonib " ]1[ ]2[

]3[ na si ) noisserpxe fo etinif morf detcurtsnoc htgnel selbairav sa nwonk osla( setanimretedni dna )stnatsnoc fo snoitarepo eht ylno gnisu , noitidda , noitcartbus , noitacilpitlum non dna , - evitagen regetni stnenopxe ,elpmaxe roF . x2 4 − x tub ,laimonylop a si 7 + x2 /4 − x 7 + x 2/3 dnoces sti esuaceb ,ton si mret

elbairav eht yb noisivid sevlovni x a ton si taht tnenopxe na sniatnoc mret driht sti esuaceb dna )x/4( eb nac taht seititnauq rof ,evitcejda na sa desu eb osla nac "laimonylop" mret ehT .)2/3( rebmun elohw

sa ,retemarap emos fo laimonylop a sa desserpxe " ni emit laimonylop ni desu si hcihw " lanoitatupmoct ytixelpmoc yroeh .

ot desu era yeht ,elpmaxe roF .ecneics dna scitamehtam fo saera fo yteirav ediw a ni raeppa slaimonyloP yratnemele morf ,smelborp fo egnar ediw a edocne hcihw ,snoitauqe laimonylop mrof smelborp drow ot

secneics eht ni smelborp detacilpmoc .

fo mus a gnivlovni noisserpxe lacitamehtam a si laimonylop A srewop erom ro eno ni selbairav yb deilpitlum stneiciffeoc a ,.e.i( elbairav eno ni laimonylop A . laimonylop etairavinu tnatsnoc htiw )

stneiciffeoc yb nevig si

)1(

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 94

esle {

;pmet*edontcurts toor=pmet - ;txen>

toor - pmet=txen> - ;txen> p d%sideueuqeDeulaV“(ftnir \ pmet,”n - ;)eulav>

;)pmet(eerf } }

)(niamdiov {

;eueuq_elpmasedontcurts ;)eueuq_elpmas&(tinI

;)01,eueuq_elpmas&(eueuqnE ;)05,eueuq_elpmas&(eueuqnE ;)075,eueuq_elpmas&(eueuqnE ;)0175,eueuq_elpmas&(eueuqnE

;)eueuq_elpmas&(eueuqeD euqeD ;)eueuq_elpmas&(eu

;)eueuq_elpmas&(eueuqeD }

:slaimonyloP .4.4 nI scitamehtam a , laimonylop keerG morf( ylop nitaL laveidem dna "ynam" , muimonib " , laimonib " ]1[ ]2[

]3[ na si ) noisserpxe fo etinif morf detcurtsnoc htgnel selbairav sa nwonk osla( setanimretedni dna )stnatsnoc fo snoitarepo eht ylno gnisu , noitidda , noitcartbus , noitacilpitlum non dna , - evitagen regetni stnenopxe ,elpmaxe roF . x2 4 − x tub ,laimonylop a si 7 + x2 /4 − x 7 + x 2/3 dnoces sti esuaceb ,ton si mret

elbairav eht yb noisivid sevlovni x a ton si taht tnenopxe na sniatnoc mret driht sti esuaceb dna )x/4( eb nac taht seititnauq rof ,evitcejda na sa desu eb osla nac "laimonylop" mret ehT .)2/3( rebmun elohw

sa ,retemarap emos fo laimonylop a sa desserpxe " ni emit laimonylop ni desu si hcihw " lanoitatupmoct ytixelpmoc yroeh .

ot desu era yeht ,elpmaxe roF .ecneics dna scitamehtam fo saera fo yteirav ediw a ni raeppa slaimonyloP yratnemele morf ,smelborp fo egnar ediw a edocne hcihw ,snoitauqe laimonylop mrof smelborp drow ot

secneics eht ni smelborp detacilpmoc .

fo mus a gnivlovni noisserpxe lacitamehtam a si laimonylop A srewop erom ro eno ni selbairav yb deilpitlum stneiciffeoc a ,.e.i( elbairav eno ni laimonylop A . laimonylop etairavinu tnatsnoc htiw )

stneiciffeoc yb nevig si

)1(

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 94

esle {

;pmet*edontcurts toor=pmet - ;txen>

toor - pmet=txen> - ;txen> p d%sideueuqeDeulaV“(ftnir \ pmet,”n - ;)eulav>

;)pmet(eerf } }

)(niamdiov {

;eueuq_elpmasedontcurts ;)eueuq_elpmas&(tinI

;)01,eueuq_elpmas&(eueuqnE ;)05,eueuq_elpmas&(eueuqnE ;)075,eueuq_elpmas&(eueuqnE ;)0175,eueuq_elpmas&(eueuqnE

;)eueuq_elpmas&(eueuqeD euqeD ;)eueuq_elpmas&(eu

;)eueuq_elpmas&(eueuqeD }

:slaimonyloP .4.4 nI scitamehtam a , laimonylop keerG morf( ylop nitaL laveidem dna "ynam" , muimonib " , laimonib " ]1[ ]2[

]3[ na si ) noisserpxe fo etinif morf detcurtsnoc htgnel selbairav sa nwonk osla( setanimretedni dna )stnatsnoc fo snoitarepo eht ylno gnisu , noitidda , noitcartbus , noitacilpitlum non dna , - evitagen regetni stnenopxe ,elpmaxe roF . x2 4 − x tub ,laimonylop a si 7 + x2 /4 − x 7 + x 2/3 dnoces sti esuaceb ,ton si mret

elbairav eht yb noisivid sevlovni x a ton si taht tnenopxe na sniatnoc mret driht sti esuaceb dna )x/4( eb nac taht seititnauq rof ,evitcejda na sa desu eb osla nac "laimonylop" mret ehT .)2/3( rebmun elohw

sa ,retemarap emos fo laimonylop a sa desserpxe " ni emit laimonylop ni desu si hcihw " lanoitatupmoct ytixelpmoc yroeh .

ot desu era yeht ,elpmaxe roF .ecneics dna scitamehtam fo saera fo yteirav ediw a ni raeppa slaimonyloP yratnemele morf ,smelborp fo egnar ediw a edocne hcihw ,snoitauqe laimonylop mrof smelborp drow ot

secneics eht ni smelborp detacilpmoc .

fo mus a gnivlovni noisserpxe lacitamehtam a si laimonylop A srewop erom ro eno ni selbairav yb deilpitlum stneiciffeoc a ,.e.i( elbairav eno ni laimonylop A . laimonylop etairavinu tnatsnoc htiw )

stneiciffeoc yb nevig si

)1(

Page 50: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 05

eht htiw sdnammus laudividni ehT stneiciffeoc dellac era dedulcni )yllausu( slaimonom dna rekceB(

.p ,3991 gninnefpsieW mrof eht fo stcudorp eht saerehw ,)191 htiw ,.e.i ,esac etairavitlum eht ni dellac era ,dettimo stneiciffeoc eht smret .p ,3991 gninnefpsieW dna rekceB( mret eht ,revewoH .)881

sdnammus laimonylop naem ot desu osla semitemos si "laimonom" tuohtiw ni dna ,stneiciffeoc riehtet dna laimonom fo snoitinifed eht ,skrow redlo emos ni dedeen erofereht si eraC .desrever era mr

.segasu gnitcilfnoc eseht hsiugnitsid ot gnitpmetta

tsehgih ehT rewop sti dellac si laimonylop etairavinu a ni redro .eerged sti semitemos ro ,

laimonylop ynA htiw sa desserpxe eb nac

)2(

stoor eht revo snur tcudorp eht erehw fo detnuoc era stoor elpitlum taht dootsrednu si ti dna .yticilpitlum htiw

a ,.e.i( selbairav owt ni laimonylop A laimonylop etairavib tnatsnoc htiw ) stneiciffeoc yb nevig si

)3(

ylop owt fo mus ehT eht rehtegot gnidda yb deniatbo si slaimon stneiciffeoc fo srewop emas eht gnirahsselbairav emas eht ,.e.i( smret ,elpmaxe rof ,os )

)4(

eht fo redro mumixam eht ot lauqe ro )smret gnidael fo noitallecnac fo esac eht ni( naht ssel redro sah dnaimonylop owt fo tcudorp eht ,ylralimiS .slaimonylop owt lanigiro yb mret gniylpitlum yb deniatbo si sla

elpmaxe rof ,stluser eht gninibmoc dna mret

5

6

.slaimonylop lanigiro owt eht fo sredro eht fo mus eht ot lauqe redro sah dna

A tneitouq laimonylop

)7(

slaimonylop owt fo dna a sa nwonk si noitcnuf lanoitar a hcus gnimrofrep fo ssecorp ehT . dellac si noisivid noisivid gnol htiw , noisivid citehtnys eht gnidrocer fo dohtem deifilpmis a gnieb

laimonylop yna roF .noisivid , sedivid inaem , si tneitouq laimonylop eht taht gn a laimonylop lanoitar na fo esac eht ni ,ro laimonylop regetni .N( laimonylop regetni rehtona , .srep ,otaS

.voN ,.mmoc .)4002 ,32

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 05

eht htiw sdnammus laudividni ehT stneiciffeoc dellac era dedulcni )yllausu( slaimonom dna rekceB(

.p ,3991 gninnefpsieW mrof eht fo stcudorp eht saerehw ,)191 htiw ,.e.i ,esac etairavitlum eht ni dellac era ,dettimo stneiciffeoc eht smret .p ,3991 gninnefpsieW dna rekceB( mret eht ,revewoH .)881

sdnammus laimonylop naem ot desu osla semitemos si "laimonom" tuohtiw ni dna ,stneiciffeoc riehtet dna laimonom fo snoitinifed eht ,skrow redlo emos ni dedeen erofereht si eraC .desrever era mr

.segasu gnitcilfnoc eseht hsiugnitsid ot gnitpmetta

tsehgih ehT rewop sti dellac si laimonylop etairavinu a ni redro .eerged sti semitemos ro ,

laimonylop ynA htiw sa desserpxe eb nac

)2(

stoor eht revo snur tcudorp eht erehw fo detnuoc era stoor elpitlum taht dootsrednu si ti dna .yticilpitlum htiw

a ,.e.i( selbairav owt ni laimonylop A laimonylop etairavib tnatsnoc htiw ) stneiciffeoc yb nevig si

)3(

ylop owt fo mus ehT eht rehtegot gnidda yb deniatbo si slaimon stneiciffeoc fo srewop emas eht gnirahsselbairav emas eht ,.e.i( smret ,elpmaxe rof ,os )

)4(

eht fo redro mumixam eht ot lauqe ro )smret gnidael fo noitallecnac fo esac eht ni( naht ssel redro sah dnaimonylop owt fo tcudorp eht ,ylralimiS .slaimonylop owt lanigiro yb mret gniylpitlum yb deniatbo si sla

elpmaxe rof ,stluser eht gninibmoc dna mret

5

6

.slaimonylop lanigiro owt eht fo sredro eht fo mus eht ot lauqe redro sah dna

A tneitouq laimonylop

)7(

slaimonylop owt fo dna a sa nwonk si noitcnuf lanoitar a hcus gnimrofrep fo ssecorp ehT . dellac si noisivid noisivid gnol htiw , noisivid citehtnys eht gnidrocer fo dohtem deifilpmis a gnieb

laimonylop yna roF .noisivid , sedivid inaem , si tneitouq laimonylop eht taht gn a laimonylop lanoitar na fo esac eht ni ,ro laimonylop regetni .N( laimonylop regetni rehtona , .srep ,otaS

.voN ,.mmoc .)4002 ,32

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 05

eht htiw sdnammus laudividni ehT stneiciffeoc dellac era dedulcni )yllausu( slaimonom dna rekceB(

.p ,3991 gninnefpsieW mrof eht fo stcudorp eht saerehw ,)191 htiw ,.e.i ,esac etairavitlum eht ni dellac era ,dettimo stneiciffeoc eht smret .p ,3991 gninnefpsieW dna rekceB( mret eht ,revewoH .)881

sdnammus laimonylop naem ot desu osla semitemos si "laimonom" tuohtiw ni dna ,stneiciffeoc riehtet dna laimonom fo snoitinifed eht ,skrow redlo emos ni dedeen erofereht si eraC .desrever era mr

.segasu gnitcilfnoc eseht hsiugnitsid ot gnitpmetta

tsehgih ehT rewop sti dellac si laimonylop etairavinu a ni redro .eerged sti semitemos ro ,

laimonylop ynA htiw sa desserpxe eb nac

)2(

stoor eht revo snur tcudorp eht erehw fo detnuoc era stoor elpitlum taht dootsrednu si ti dna .yticilpitlum htiw

a ,.e.i( selbairav owt ni laimonylop A laimonylop etairavib tnatsnoc htiw ) stneiciffeoc yb nevig si

)3(

ylop owt fo mus ehT eht rehtegot gnidda yb deniatbo si slaimon stneiciffeoc fo srewop emas eht gnirahsselbairav emas eht ,.e.i( smret ,elpmaxe rof ,os )

)4(

eht fo redro mumixam eht ot lauqe ro )smret gnidael fo noitallecnac fo esac eht ni( naht ssel redro sah dnaimonylop owt fo tcudorp eht ,ylralimiS .slaimonylop owt lanigiro yb mret gniylpitlum yb deniatbo si sla

elpmaxe rof ,stluser eht gninibmoc dna mret

5

6

.slaimonylop lanigiro owt eht fo sredro eht fo mus eht ot lauqe redro sah dna

A tneitouq laimonylop

)7(

slaimonylop owt fo dna a sa nwonk si noitcnuf lanoitar a hcus gnimrofrep fo ssecorp ehT . dellac si noisivid noisivid gnol htiw , noisivid citehtnys eht gnidrocer fo dohtem deifilpmis a gnieb

laimonylop yna roF .noisivid , sedivid inaem , si tneitouq laimonylop eht taht gn a laimonylop lanoitar na fo esac eht ni ,ro laimonylop regetni .N( laimonylop regetni rehtona , .srep ,otaS

.voN ,.mmoc .)4002 ,32

Page 51: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 15

eht gnignahcxE stneiciffeoc a fo laimonylop etairavinu dne - ot - laimonylop a secudorp dne

)8(

esohW stoor era slacorpicer lanigiro eht fo stoor .

elur s'renroH sti fo tsil a morf laimonylop a gnimrof fo dohtem tneiciffe yllanoitatupmoc a sedivorp ni detnemelpmi eb nac dna ,stneiciffeoc acitamehtaM .swollof sa

]l ,0 ,&2# + 1# x[dloF =: ]_x ,tsiL_l[laimonyloP

.sredro wol fo slaimonylop ot nevig seman laiceps sevig elbat gniwollof ehT

redro laimonylop eman laimonylop

2 laimonylop citardauq

3 laimonylop cibuc

4 citrauq

5 citniuq

6 citxes

wef a fi snoitidda evif dna snoitacilpitlum eerht gnisu detupmoc eb yam eerged htruof fo slaimonyloP sserP( tsrif detaluclac era seititnauq .la te :)9891

)9(

erehw )01(

)11(

)21(

)31(

)41(

a ,ylralimiS dna ,snoitidda evif dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htfif fo laimonylopsnoitidda neves dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htxis fo laimonylop a fo esu ehT.

nac eW .snoitarepo laimonylop ot detius llew si stsil deknil fo noitcelloc a gnitirw enigami ylisae sa stsil deknil gnisu slaimonylop fo noitacilpitlum dna noitcartbus ,noitidda tuptuo ,tupni rof serudecorp

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 15

eht gnignahcxE stneiciffeoc a fo laimonylop etairavinu dne - ot - laimonylop a secudorp dne

)8(

esohW stoor era slacorpicer lanigiro eht fo stoor .

elur s'renroH sti fo tsil a morf laimonylop a gnimrof fo dohtem tneiciffe yllanoitatupmoc a sedivorp ni detnemelpmi eb nac dna ,stneiciffeoc acitamehtaM .swollof sa

]l ,0 ,&2# + 1# x[dloF =: ]_x ,tsiL_l[laimonyloP

.sredro wol fo slaimonylop ot nevig seman laiceps sevig elbat gniwollof ehT

redro laimonylop eman laimonylop

2 laimonylop citardauq

3 laimonylop cibuc

4 citrauq

5 citniuq

6 citxes

wef a fi snoitidda evif dna snoitacilpitlum eerht gnisu detupmoc eb yam eerged htruof fo slaimonyloP sserP( tsrif detaluclac era seititnauq .la te :)9891

)9(

erehw )01(

)11(

)21(

)31(

)41(

a ,ylralimiS dna ,snoitidda evif dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htfif fo laimonylopsnoitidda neves dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htxis fo laimonylop a fo esu ehT.

nac eW .snoitarepo laimonylop ot detius llew si stsil deknil fo noitcelloc a gnitirw enigami ylisae sa stsil deknil gnisu slaimonylop fo noitacilpitlum dna noitcartbus ,noitidda tuptuo ,tupni rof serudecorp

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 15

eht gnignahcxE stneiciffeoc a fo laimonylop etairavinu dne - ot - laimonylop a secudorp dne

)8(

esohW stoor era slacorpicer lanigiro eht fo stoor .

elur s'renroH sti fo tsil a morf laimonylop a gnimrof fo dohtem tneiciffe yllanoitatupmoc a sedivorp ni detnemelpmi eb nac dna ,stneiciffeoc acitamehtaM .swollof sa

]l ,0 ,&2# + 1# x[dloF =: ]_x ,tsiL_l[laimonyloP

.sredro wol fo slaimonylop ot nevig seman laiceps sevig elbat gniwollof ehT

redro laimonylop eman laimonylop

2 laimonylop citardauq

3 laimonylop cibuc

4 citrauq

5 citniuq

6 citxes

wef a fi snoitidda evif dna snoitacilpitlum eerht gnisu detupmoc eb yam eerged htruof fo slaimonyloP sserP( tsrif detaluclac era seititnauq .la te :)9891

)9(

erehw )01(

)11(

)21(

)31(

)41(

a ,ylralimiS dna ,snoitidda evif dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htfif fo laimonylopsnoitidda neves dna snoitacilpitlum ruof htiw detupmoc eb yam eerged htxis fo laimonylop a fo esu ehT.

nac eW .snoitarepo laimonylop ot detius llew si stsil deknil fo noitcelloc a gnitirw enigami ylisae sa stsil deknil gnisu slaimonylop fo noitacilpitlum dna noitcartbus ,noitidda tuptuo ,tupni rof serudecorp

Page 52: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 25

slaimonylop ni daer ot gnihsiw resu lacitehtopyh A .noitatneserper fo snaem eht A(x) B , (x dna ) C(x dna )c neht etupmo D(x = ) A(x * ) B(x + ) C(x :margorp niam sih ni etirw dluow )

llac DAER (A) llac DAER (B) llac DAER (C)

T LUMP ( B ,A ) D DDAP ( C ,T ) llac TNIRP (D)

ot lufesu eb dluow ti tniop siht tA .slaimonylop erom gnitupmoc eunitnoc ot hsiw yam resu ruo woNht mialcer laitrap a sa ylno detaerc saw laimonylop sihT .)x(T tneserper ot desu gnieb era hcihw sedon e

rehto dloh ot desu eb yam yeht ,)x(T fo sedon eht gninruter yB .)x(D rewsna eht sdrawot tluser .slaimonylop

erudecorp ESARE (T) fo sedon eht lla nruter// T detaeper gnidiova tsil ecaps elbaliava eht ot

erudecorp ot sllac TER // fi = T 0 nruter neht

p T elihw KNIL (p 0 ) od fo dne eht dnif// T //

p KNIL (p) dne

KNlL (p ) VA // p fo edon tsal eht ot stniop T // VA T edulcni won tsil elbaliava// s T // dne ESARE

fo sedon eht nruter ot erudecorp TER eht gnisu sdiova ylrevelc tI .ylluferac mhtirogla siht ydutS T eno fo sedon eht taht tcaf eht fo esu sekam tub ,emit a ta edon T esare ot deriuqer emit ehT .deknil ydaerla era

T(x lanoitroporp llits si ) ni sedon fo rebmun eht ot T tuo deirrac eb nac slaimonylop eritne fo gnisare sihT . ot kcab stniop edon tsal eht fo dleif KNIL eht taht os erutcurts tsil eht gniyfidom yb yltneiciffe erom neve

p edon tsal eht hcihw ni tsil A .8.4 erugif ni sa edon tsrif eht a demret eb lliw tsrif eht ot kcab stniotsil ralucric A . niahc .dleif knil orez a sah edon tsal eht hcihw ni tsil deknil ylgnis a si

ehT .tsil eht ni sedon fo rebmun eht fo tnednepedni emit fo tnuoma dexif a ni desare eb yam stsil ralucriCwoleb mhtirogla .siht seod

erudecorp ESAREC (T) tsil ralucric eht nruter// T //loop elbaliava eht ot

fi T 0 = ;nruter neht X KNIL (T)

KNIL (T ) VA VA X dne ESAREC

:snoitarepo tsiL lanoitiddA .5.4 emoS .stsil deknil ylgnis gnitalupinam rof senituor fo yteirav a dliub ot elbarised dna yrassecen netfo si tI

eht rehtegot sknil yllanigiro hcihw TINI )1 :era nees ydaerla evah ew taht VA )3 dna EDONTEG )2 ;tsil ot sedon nruter dna teg hcihw TER VA ehtonA . sihT .niahc a strevni hcihw eno si noitarepo lufesu r

.sretniop 3 fo esu ekam ew fi "ecalp ni" enod eb nac ti esuaceb gnitseretni yllaicepse si enituor

Page 53: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 35

erudecorp TREVNI (X) yb ta detniop niahc a// X fi taht os detrevni si X ( = a1 ,... , am)

noitucexe retfa neht X ( = am ,... , a1 //) p X;q 0

elihw p 0 od r q; q p // r swollof q ;q swollof p // p KNIL (p // ) p //edon txen ot sevom

KNIL (q ) r knil// q //edon suoiverp ot dne

X q dne TREVNI

2 dna 1 htgnel fo stsil dna ,tsil ytpme eht :selpmaxe 3 tsael ta no tuo mhtirogla siht yrt dluohs redaer ehT fo tsil a roF .msinahcem eht sdnatsrednu eh taht flesmih ecnivnoc ot m eht ,sedon 1 elihw si pool

detucexe m nil si emit gnitupmoc eht os dna semit ro rae O(m .)

sniahc owt setanetacnoc hcihw eno si enituorbus lufesu rehtonA X dna Y .

erudecorp ETANETACNOC ( Z ,Y ,X ) // X ( = a1 ,... , am ,) Y ( = b1 ,... , bn ,) n,m niahc wen a secudorp ,0

Z ( = a1 ,... , am,b1 ,... , bn //) X Z

fi X 0 = neht [ Y Z ; nruter ] fi Y 0 = nruter neht

X p elihw KNIL (p 0 ) od fo edon tsal dnif// X //

p KNIL (p) dne

KNIL (p ) Y //Y ot X fo edon tsal knil// dne ETANETACNOC

ot recin si ti weiv fo tniop citehtsea na morF .tsil tsrif eht fo htgnel eht ni raenil osla si mhtirogla sihT :ekil kool dluow sihT .SKRAPS ni tnemetats esac eht gnisu erudecorp siht etirw

erudecorp ETANETACNOC ( Z ,Y ,X ) esac

: Y Z: 0 = X : X Z : 0 = Y : esle : X Z ;X p

elihw KNIL (p 0 ) od KNIL p (p)

dne KNIL (p ) Y

dne dne ETANETACNOC

eht fo dleif KNIL eht egnahc ot evah eW .tsil siht fo tnorf eht ta edon wen a tresni ot tnaw ew esoppuS

gniniatnoc edon x3 fo htgnel eritne eht nwod evom ew taht seriuqer sihT . A tI .edon tsal eht dnif ew litnu.tsrif eht naht rehtar edon tsal eht ot stniop tsil ralucric a fo eman eht fi tneinevnoc erom si

Page 54: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 45

eht ta ro tnorf eht ta edon a tresni hcihw serudecorp etirw nac ew woN a ekat dna tsil ralucric a fo raer .emit fo tnuoma dexif

erudecorp TNORF__TRESNI ( X ,A ) tsil ralucric eht fo tnorf eht ot X yb ta detniop edon eht tresni//

//edon tsal eht ot stniop A erehw ,A fi 0 = A neht [A X

KNIL (X ) A] esle [ KNIL (X ) KNIL (A) KNIL (A ) X]

dne TRESNI -- TNORF

tresni oT X tnemetats lanoitidda eht dda ot sdeen ylno eno ,raer eht ta A X eht ot esle fo esualc _TRESNI -.TNORF_

htgnel eht senimreted hcihw noitcnuf a etirw ew ,stsil ralucric rof erudecorp elpmis a fo elpmaxe tsal a sA .tsil a hcus fo

erudecorp HTGNEL (A) tsil ralucric eht fo htgnel eht dnif// A //

i 0 fi 0 A neht [ rtp A

taeper i i ;1 + rtp (KNIL rtp )

litnu rtp = A ] nruter (i)

dne HTGNEL

.6.4 secirtaM esrapS :

A xirtam esraps a si xirtam ( sorez htiw yliramirp detalupop 2002 hcsriluB & reotS .p , mret ehT .)916 yb denioc saw flesti ztiwokraM .M yrraH .

noC sllab fo enil a redisnoC .delpuoc ylesool era hcihw smetsys ot sdnopserroc ytisraps ,yllautpec sllab fo enil emas eht fi ,tsartnoc yB .metsys esraps a si siht ;txen eht ot eno morf sgnirps yb detcennoc

t ,sllab rehto lla ot llab hcae gnitcennoc sgnirps dah a yb detneserper eb dluow metsys eh xirtam esned . ni lufesu si ytisraps fo tpecnoc ehT scirotanibmoc sa hcus saera noitacilppa dna yroeht krowten hcihw ,

.snoitcennoc ro atad tnacifingis fo ytisned wol a evah

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps Aoh" enifed ot spleh noitinifed sihT .stnemele ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam w

roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo erutcurts eht tahw no sdneped ti taht si rewsna esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

am sekat ti ecnis )sdohtem tcerid rof( nosnikliW fo esnes eht ni esraps ton si xirt .

xirtam esraps a gnitaerC

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 45

eht ta ro tnorf eht ta edon a tresni hcihw serudecorp etirw nac ew woN a ekat dna tsil ralucric a fo raer .emit fo tnuoma dexif

erudecorp TNORF__TRESNI ( X ,A ) tsil ralucric eht fo tnorf eht ot X yb ta detniop edon eht tresni//

//edon tsal eht ot stniop A erehw ,A fi 0 = A neht [A X

KNIL (X ) A] esle [ KNIL (X ) KNIL (A) KNIL (A ) X]

dne TRESNI -- TNORF

tresni oT X tnemetats lanoitidda eht dda ot sdeen ylno eno ,raer eht ta A X eht ot esle fo esualc _TRESNI -.TNORF_

htgnel eht senimreted hcihw noitcnuf a etirw ew ,stsil ralucric rof erudecorp elpmis a fo elpmaxe tsal a sA .tsil a hcus fo

erudecorp HTGNEL (A) tsil ralucric eht fo htgnel eht dnif// A //

i 0 fi 0 A neht [ rtp A

taeper i i ;1 + rtp (KNIL rtp )

litnu rtp = A ] nruter (i)

dne HTGNEL

.6.4 secirtaM esrapS :

A xirtam esraps a si xirtam ( sorez htiw yliramirp detalupop 2002 hcsriluB & reotS .p , mret ehT .)916 yb denioc saw flesti ztiwokraM .M yrraH .

noC sllab fo enil a redisnoC .delpuoc ylesool era hcihw smetsys ot sdnopserroc ytisraps ,yllautpec sllab fo enil emas eht fi ,tsartnoc yB .metsys esraps a si siht ;txen eht ot eno morf sgnirps yb detcennoc

t ,sllab rehto lla ot llab hcae gnitcennoc sgnirps dah a yb detneserper eb dluow metsys eh xirtam esned . ni lufesu si ytisraps fo tpecnoc ehT scirotanibmoc sa hcus saera noitacilppa dna yroeht krowten hcihw ,

.snoitcennoc ro atad tnacifingis fo ytisned wol a evah

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps Aoh" enifed ot spleh noitinifed sihT .stnemele ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam w

roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo erutcurts eht tahw no sdneped ti taht si rewsna esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

am sekat ti ecnis )sdohtem tcerid rof( nosnikliW fo esnes eht ni esraps ton si xirt .

xirtam esraps a gnitaerC

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 45

eht ta ro tnorf eht ta edon a tresni hcihw serudecorp etirw nac ew woN a ekat dna tsil ralucric a fo raer .emit fo tnuoma dexif

erudecorp TNORF__TRESNI ( X ,A ) tsil ralucric eht fo tnorf eht ot X yb ta detniop edon eht tresni//

//edon tsal eht ot stniop A erehw ,A fi 0 = A neht [A X

KNIL (X ) A] esle [ KNIL (X ) KNIL (A) KNIL (A ) X]

dne TRESNI -- TNORF

tresni oT X tnemetats lanoitidda eht dda ot sdeen ylno eno ,raer eht ta A X eht ot esle fo esualc _TRESNI -.TNORF_

htgnel eht senimreted hcihw noitcnuf a etirw ew ,stsil ralucric rof erudecorp elpmis a fo elpmaxe tsal a sA .tsil a hcus fo

erudecorp HTGNEL (A) tsil ralucric eht fo htgnel eht dnif// A //

i 0 fi 0 A neht [ rtp A

taeper i i ;1 + rtp (KNIL rtp )

litnu rtp = A ] nruter (i)

dne HTGNEL

.6.4 secirtaM esrapS :

A xirtam esraps a si xirtam ( sorez htiw yliramirp detalupop 2002 hcsriluB & reotS .p , mret ehT .)916 yb denioc saw flesti ztiwokraM .M yrraH .

noC sllab fo enil a redisnoC .delpuoc ylesool era hcihw smetsys ot sdnopserroc ytisraps ,yllautpec sllab fo enil emas eht fi ,tsartnoc yB .metsys esraps a si siht ;txen eht ot eno morf sgnirps yb detcennoc

t ,sllab rehto lla ot llab hcae gnitcennoc sgnirps dah a yb detneserper eb dluow metsys eh xirtam esned . ni lufesu si ytisraps fo tpecnoc ehT scirotanibmoc sa hcus saera noitacilppa dna yroeht krowten hcihw ,

.snoitcennoc ro atad tnacifingis fo ytisned wol a evah

orez fo rebmun egral eht fo egatnavda ekat ot seuqinhcet laiceps swolla taht xirtam a si xirtam esraps Aoh" enifed ot spleh noitinifed sihT .stnemele ehT ".esraps" eb ot redro ni sdeen xirtam a sorez "ynam w

roF .ti htiw od ot tnaw uoy tahw dna ,si xirtam eht fo erutcurts eht tahw no sdneped ti taht si rewsna esraps detareneg ylmodnar a ,elpmaxe htiw xirtam eht tuohguorht ylmodnar derettacs seirtne

am sekat ti ecnis )sdohtem tcerid rof( nosnikliW fo esnes eht ni esraps ton si xirt .

xirtam esraps a gnitaerC

Page 55: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 55

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerclpmaxe roF .tamrof esraps ni derots xirtam :e

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

1 0 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - imusnoc dnammoc ehT .tamrof esned ni ti etaerc tsrif ot gn )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 55

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerclpmaxe roF .tamrof esraps ni derots xirtam :e

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

1 0 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - imusnoc dnammoc ehT .tamrof esned ni ti etaerc tsrif ot gn )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 55

xirtam a fI A dnammoc eht neht ,tamrof )esned( yranidro ni derots si )A(esraps = S eht fo ypoc a setaerclpmaxe roF .tamrof esraps ni derots xirtam :e

0;2 0 1;1 0 0[ = A >> - ]0 3

= A

1 0 0

2 0 1

0 - 0 3

)A(esraps = S >>

= S

1 )1,2(

)2,3( -3

1 )3,1(

2 )3,2(

sohw >>

ssalC setyB eziS emaN

yarra elbuod 27 3x3 A

yarra esraps 46 3x3 S

setyb 631 gnisu stnemele 31 si latot dnarG

eht fo mrof siht ,yletanutrofnU esraps fi ecnis ,lufesu ylralucitrap ton si dnammoc A eb nac ti ,egral siemit yrev - imusnoc dnammoc ehT .tamrof esned ni ti etaerc tsrif ot gn )n,m(esraps = S na setaerc

eno dedda eb neht nac seirtnE .tamrof esraps ni xirtam orez - yb - :eno

)2,3(esraps = A >>

= A

3 :esraps orez llA - yb -2

;1=)2,1(A >>

;4=)1,3(A >>

Page 56: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 65

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

ht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehT oreznon wef a htiw xirtam a ,si ta eht htiw detaerc eb nac xirtam a hcuS .slanogaid sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 0 0 61

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 0 0 61 46 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - a ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lanogaid niam eht( 3 dn - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot uoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager ,slanogaid eht ,esr suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 65

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

ht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehT oreznon wef a htiw xirtam a ,si ta eht htiw detaerc eb nac xirtam a hcuS .slanogaid sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 0 0 61

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 0 0 61 46 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - a ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lanogaid niam eht( 3 dn - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot uoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager ,slanogaid eht ,esr suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 65

=)2,3(A >> - ;1

A >>

= A

4 )1,3(

1 )2,1(

)2,3( -1

).pool a ni dedda eb dluow soreznon eht ,lufesu ylurt eb ot siht rof ,esruoc fO(

eht fo noisrev rehtonA esraps si dnammoc )znxam,n,m,S,J,I(esraps = S na setaerc sihT . esraps

( yrtne htiw xirtam I(k ,) J(k ot lauqe )) tnemugra lanoitpo ehT . znxam erp ot baltaM sesuac - rof egarots etacolla znxam eht ni ycneiciffe esaercni nac hcihw ,seirtne oreznon

ot retal dedda eb lliw soreznon erom nehw esac S .

ht ,xirtam dednab a si xirtam esraps fo epyt nommoc tsom ehT oreznon wef a htiw xirtam a ,si ta eht htiw detaerc eb nac xirtam a hcuS .slanogaid sgaidps :xirtam gniwollof eht redisnoC .dnammoc

A >>

= A

46 - 0 61 - 0 0 0 0 0 61

- 46 61 - 0 61 - 0 0 0 0 61

0 - 0 0 46 61 - 0 0 0 61

- 46 0 0 61 - 0 61 - 0 0 61

0 - 0 61 - 46 61 - 0 61 - 0 61

0 0 - 0 61 - 0 0 46 61 - 61

0 0 0 - 0 0 61 46 - 0 61

0 0 0 0 - 0 61 - 46 61 - 61

0 0 0 0 0 - 0 61 - 46 61

a si sihT A fo slanogaid oreznon eht ,emehcs gnixedni s'baltaM nI .slanogaid oreznon 5 htiw xirtam srebmun era - ,3 - a ,1 ,0 ,1 rebmun si lanogaidbus tsrif eht ,0 rebmun si lanogaid niam eht( 3 dn - tsrif eht ,1

yrassecen tsrif si ti ,tamrof esraps ni xirtam emas eht etaerc oT .)htrof os dna ,1 rebmun si lanogaidrepus

a etaerc ot uoc fO .A fo slanogaid oreznon eht gniniatnoc xirtam sa dedrager ,slanogaid eht ,esr suoirav eht rehtag ot redro nI .9 htgnel sah lanogaid niam eht ylno ;shtgnel tnereffid evah ,srotcev nmuloc

Page 57: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 75

artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaida og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidbus rof mottob eht t

:xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 46 0 61 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocni eht sdeen :slanogaid eht fo secid

[ = d >> - ,3 - ;]3,1,0,1

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

i ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahreP n dnammoc eht gnisu ,tamrof esned eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps si dnammoc lufesu rehtonA . yps a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe roF .xirtam - xirtam lanogaid A nac ees ;dnammoc gniwollof eht yb deyalpsid eb

erugiF 6 :

)A(yps >>

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 75

artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaida og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidbus rof mottob eht t

:xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 46 0 61 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocni eht sdeen :slanogaid eht fo secid

[ = d >> - ,3 - ;]3,1,0,1

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

i ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahreP n dnammoc eht gnisu ,tamrof esned eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps si dnammoc lufesu rehtonA . yps a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe roF .xirtam - xirtam lanogaid A nac ees ;dnammoc gniwollof eht yb deyalpsid eb

erugiF 6 :

)A(yps >>

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 75

artxe eht taht si elur ehT .sorez htiw deddap eb tsum slanogaid retrohs eht ,xirtam elgnis a ni slanogaida og sorez gniwollof eht etaerc ew suhT .slanogaidrepus rof pot eht ta dna slanogaidbus rof mottob eht t

:xirtam

[ = B >>

- 61 - 0 0 46 61

- 61 - 46 61 - 0 61

- 46 0 61 - 0 61

- 61 - 0 46 61 - 61

- 61 - 46 61 - 61 - 61

- 46 0 61 - 61 - 61

0 - 0 46 61 - 61

0 - 46 61 - 61 - 61

46 0 0 - 61 - 61

;]

ehT .)senil lareves no xirtam egral a fo swor eht gniretne rof euqinhcet eht eciton( sgaidps osla dnammocni eht sdeen :slanogaid eht fo secid

[ = d >> - ,3 - ;]3,1,0,1

:swollof sa detaerc neht si xirtam ehT

;)9,9,d,B(sgaidps = S

fo ezis eht evig stnemugra owt tsal ehT S .

i ,detaerc eb nac xirtam ytitnedi na taht llaceR .ytitnedi eht si xirtam esraps nommoc tsom eht spahreP n dnammoc eht gnisu ,tamrof esned eye eht etaerc oT . esu ,tamrof esraps ni xirtam ytitnedi = I

)n(eyeps si dnammoc lufesu rehtonA . yps a fo nrettap ytisraps eht gniyalpsid cihparg a setaerc hcihw ,atnep evoba eht ,elpmaxe roF .xirtam - xirtam lanogaid A nac ees ;dnammoc gniwollof eht yb deyalpsid eb

erugiF 6 :

)A(yps >>

Page 58: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 85

:6 erugiF xirtam a fo nrettap ytisraps ehT

7.4 stsiL dekniL ylbuoD . :

sah tsil deknil ylralucric a hguohtlA enO .skcabward emos sah llits ti ,stsil raenil revo segatnavda tonnacelbuoD .drawkcab tsil a hcus esrevart - rieht dna , edon rep ecaps erom eriuqer stsil deknil yratnemele

yeht esuaceb etalupinam ot reisae netfo era yeht tub ;evisnepxe erom era snoitarepo laitneuqes wollaedon a eteled ro tresni nac eno ,ralucitrap nI .snoitcerid htob ni tsil eht ot ssecca fo rebmun tnatsnoc a ni

ylgnis htiw derapmoC( .sserdda s'edon taht ylno nevig snoitarepo - deknil eht eriuqer hcihw ,stsil suoiverpredro ni sserdda s'edon emoS ).eteled ro tresni yltcerroc ot .snoitcerid htob ni ssecca eriuqer smhtirogla

liat wolla ton od yeht ,dnah rehto eht nO - ,gnirahs .serutcurts atad tnetsisrep sa desu eb tonnac dna

stsiL dekniL ylbuoD no snoitarepO

o demrofrep eb nac taht noitarepo enO ot si tsil deknil yranidro no ton tub tsil deknil ylbuod n a eteleddeknil ylbuod a morfp yb detniop edon eht seteled enituor c gniwollof ehT .edon nevig sti serots dna tsil

.)p (eteled yb dellac si tI .x ni stnetnoc

) p (eteled

{

;r ,q ,p RTPEDON

;xp* tni

) LLUN = = p ( fi

{

noiteleD dioV “(ftnirp \ ;)”n

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 85

:6 erugiF xirtam a fo nrettap ytisraps ehT

7.4 stsiL dekniL ylbuoD . :

sah tsil deknil ylralucric a hguohtlA enO .skcabward emos sah llits ti ,stsil raenil revo segatnavda tonnacelbuoD .drawkcab tsil a hcus esrevart - rieht dna , edon rep ecaps erom eriuqer stsil deknil yratnemele

yeht esuaceb etalupinam ot reisae netfo era yeht tub ;evisnepxe erom era snoitarepo laitneuqes wollaedon a eteled ro tresni nac eno ,ralucitrap nI .snoitcerid htob ni tsil eht ot ssecca fo rebmun tnatsnoc a ni

ylgnis htiw derapmoC( .sserdda s'edon taht ylno nevig snoitarepo - deknil eht eriuqer hcihw ,stsil suoiverpredro ni sserdda s'edon emoS ).eteled ro tresni yltcerroc ot .snoitcerid htob ni ssecca eriuqer smhtirogla

liat wolla ton od yeht ,dnah rehto eht nO - ,gnirahs .serutcurts atad tnetsisrep sa desu eb tonnac dna

stsiL dekniL ylbuoD no snoitarepO

o demrofrep eb nac taht noitarepo enO ot si tsil deknil yranidro no ton tub tsil deknil ylbuod n a eteleddeknil ylbuod a morfp yb detniop edon eht seteled enituor c gniwollof ehT .edon nevig sti serots dna tsil

.)p (eteled yb dellac si tI .x ni stnetnoc

) p (eteled

{

;r ,q ,p RTPEDON

;xp* tni

) LLUN = = p ( fi

{

noiteleD dioV “(ftnirp \ ;)”n

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 85

:6 erugiF xirtam a fo nrettap ytisraps ehT

7.4 stsiL dekniL ylbuoD . :

sah tsil deknil ylralucric a hguohtlA enO .skcabward emos sah llits ti ,stsil raenil revo segatnavda tonnacelbuoD .drawkcab tsil a hcus esrevart - rieht dna , edon rep ecaps erom eriuqer stsil deknil yratnemele

yeht esuaceb etalupinam ot reisae netfo era yeht tub ;evisnepxe erom era snoitarepo laitneuqes wollaedon a eteled ro tresni nac eno ,ralucitrap nI .snoitcerid htob ni tsil eht ot ssecca fo rebmun tnatsnoc a ni

ylgnis htiw derapmoC( .sserdda s'edon taht ylno nevig snoitarepo - deknil eht eriuqer hcihw ,stsil suoiverpredro ni sserdda s'edon emoS ).eteled ro tresni yltcerroc ot .snoitcerid htob ni ssecca eriuqer smhtirogla

liat wolla ton od yeht ,dnah rehto eht nO - ,gnirahs .serutcurts atad tnetsisrep sa desu eb tonnac dna

stsiL dekniL ylbuoD no snoitarepO

o demrofrep eb nac taht noitarepo enO ot si tsil deknil yranidro no ton tub tsil deknil ylbuod n a eteleddeknil ylbuod a morfp yb detniop edon eht seteled enituor c gniwollof ehT .edon nevig sti serots dna tsil

.)p (eteled yb dellac si tI .x ni stnetnoc

) p (eteled

{

;r ,q ,p RTPEDON

;xp* tni

) LLUN = = p ( fi

{

noiteleD dioV “(ftnirp \ ;)”n

Page 59: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 95

;nruter

}

p = xp* - ;ofni >

p = q - ;tfel >

p = r - ;thgir >

q - ;r = thgir >

r - ;q = tfel >

;) p (edoneerf

;nruter

}

redisnoc su teL .edon nevig a fo tfel eht no ro thgir eht no detresni eb nac edon A oitresni fo edis thgir ta nhtiw edon a stresni thgir tresni enituor ehT .edon nevig a a ni )p(edon fo thgir ot x dleif noitamrofni

.tsil deknil ylbuod

{ )x ,p (thgirtresni

;r ,q ,p RTPEDON

;x tni

{ ) LLUN = = p ( fi

noitresnI dioV “(ftnirp \ ;)”n

;nruter

}

= q ;)(edonteg

q - ;x = ofni >

p = r - ;thgir >

r - ;q = tfel >

q - ;r = thgir >

q - ;p = tfel >

p - ;q = tfel >

Page 60: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 06

;nruter

}

.8.4 SNOITSEUQ DEDNEMMOCER stsiL dekniL enifeD.1

tsil deknil a ni tuo deirrac snoitarepo cisab eht nialpxe & tsiL.2

acilppa owt yna tuo tsiL.3 ylgnis revo tsil deknil ylbuod fo segatnavda owt yna dna tsil deknil fo snoit.tsil deknil

.tsil deknil ylgnis a gnisu eueuq yranidro na etalumis ot margorp C a etirW .4

eknil ylgnis nevig a rof noitisop deificeps a ta edon a tresni ot mhtirogla na eviG .5 .tsil d

:tsil deknil ylbuod a no snoitarepo gniwollof eht mrofrep ot margorp C a etirW .6

.tnorf eht ta edon hcae gnidda yb tsil a etaerc oT )i

.redro esrever eht ni stnemele eht lla yalpsid oT )ii

Page 61: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 16

TINU – 5 : SEERT – 1

noitcudortnI 1.5 : A eert eht dellac edon detangised yllaiceps a si ereht )i( :taht hcus sedon erom ro eno fo tes etinif a si

toor otni denoititrap era sedon gniniamer eht )ii( ; n stes tniojsid 0 T1 ,... , Tn a si stes eseht fo hcae erehw .eert T1 ,... , Tn eht dellac era seertbus A .toor eht fo taht os dezinagro si atad eht taht snaem erutcurts eert

ni si sesira erutcurts a hcus erehw ecalp nommoc yrev enO .sehcnarb yb detaler era noitamrofni fo smeti.seigolaeneg fo noitagitsevni eht

epyTataDtcartsbA {eert secnatsni A tes fo :stnemele

)1( ytpme ro gnivah a dehsiugnitsid toor tnemele )2( hcae non - toor tnemele gnivah yltcaxe eno tnerap tnemele snoitarepo )(toor )(eerged )k(dlihc } :seert rof ygolonimret cisab emoS

morf demrof era seerT sedon dna segde dellac semitemos era sedoN . secitrev era segdE . dellac semitemos sehcnarb .

gnidulcni seitreporp fo rebmun a evah yam sedoN eulav dna lebal . doohtnerap" dellac si noitaler siht ,eert a nI .rehto hcae ot sedon etaler ot desu era segdE ". egde nA eht sa a sehsilbatse b dna a sedon neewteb }b,a{ tnerap a dellac si b ,oslA .b fo dlihc fo

.a nI .dlihc ot tnerap morf detcerid yllaer era yeht ,senil elpmis sa nward yllausu era segde hguohtlA

pot si siht ,sgniward eert - ot - .mottob noitinifeD lamrofnI : a eert ",toor" sa dehsiugnitsid si hcihw fo eno ,sedon fo noitcelloc a si

.segde yb nwohs si taht )"doohtnerap"( noitaler a htiw gnola noitinifeD lamroF ehT .flesti fo smret ni eert senifed ti taht ni "evisrucer" si noitinifed sihT :

oc" osla si noitinifed .eert a tcurtsnoc ot woh sebircsed ti taht ni "evitcurtsn .1 ".toor" si tI .eert a si edon elgnis A .2 T dna edon a si N esoppuS 1 T , 2 T ,... , k n stoor htiw seert era 1 n , 2 n,... , k eW .ylevitcepser ,

sedon eht fo tnerap eht N gnikam yb T eert wen a tcurtsnoc nac n1 n , 2 n ,... , k si N ,nehT .T dna T fo toor eht 1 T , 2 T ,... , k .seertbus era

seertbus k gnisu detcurtsnoc ,T eert ehT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 16

TINU – 5 : SEERT – 1

noitcudortnI 1.5 : A eert eht dellac edon detangised yllaiceps a si ereht )i( :taht hcus sedon erom ro eno fo tes etinif a si

toor otni denoititrap era sedon gniniamer eht )ii( ; n stes tniojsid 0 T1 ,... , Tn a si stes eseht fo hcae erehw .eert T1 ,... , Tn eht dellac era seertbus A .toor eht fo taht os dezinagro si atad eht taht snaem erutcurts eert

ni si sesira erutcurts a hcus erehw ecalp nommoc yrev enO .sehcnarb yb detaler era noitamrofni fo smeti.seigolaeneg fo noitagitsevni eht

epyTataDtcartsbA {eert secnatsni A tes fo :stnemele

)1( ytpme ro gnivah a dehsiugnitsid toor tnemele )2( hcae non - toor tnemele gnivah yltcaxe eno tnerap tnemele snoitarepo )(toor )(eerged )k(dlihc } :seert rof ygolonimret cisab emoS

morf demrof era seerT sedon dna segde dellac semitemos era sedoN . secitrev era segdE . dellac semitemos sehcnarb .

gnidulcni seitreporp fo rebmun a evah yam sedoN eulav dna lebal . doohtnerap" dellac si noitaler siht ,eert a nI .rehto hcae ot sedon etaler ot desu era segdE ". egde nA eht sa a sehsilbatse b dna a sedon neewteb }b,a{ tnerap a dellac si b ,oslA .b fo dlihc fo

.a nI .dlihc ot tnerap morf detcerid yllaer era yeht ,senil elpmis sa nward yllausu era segde hguohtlA

pot si siht ,sgniward eert - ot - .mottob noitinifeD lamrofnI : a eert ",toor" sa dehsiugnitsid si hcihw fo eno ,sedon fo noitcelloc a si

.segde yb nwohs si taht )"doohtnerap"( noitaler a htiw gnola noitinifeD lamroF ehT .flesti fo smret ni eert senifed ti taht ni "evisrucer" si noitinifed sihT :

oc" osla si noitinifed .eert a tcurtsnoc ot woh sebircsed ti taht ni "evitcurtsn .1 ".toor" si tI .eert a si edon elgnis A .2 T dna edon a si N esoppuS 1 T , 2 T ,... , k n stoor htiw seert era 1 n , 2 n,... , k eW .ylevitcepser ,

sedon eht fo tnerap eht N gnikam yb T eert wen a tcurtsnoc nac n1 n , 2 n ,... , k si N ,nehT .T dna T fo toor eht 1 T , 2 T ,... , k .seertbus era

seertbus k gnisu detcurtsnoc ,T eert ehT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 16

TINU – 5 : SEERT – 1

noitcudortnI 1.5 : A eert eht dellac edon detangised yllaiceps a si ereht )i( :taht hcus sedon erom ro eno fo tes etinif a si

toor otni denoititrap era sedon gniniamer eht )ii( ; n stes tniojsid 0 T1 ,... , Tn a si stes eseht fo hcae erehw .eert T1 ,... , Tn eht dellac era seertbus A .toor eht fo taht os dezinagro si atad eht taht snaem erutcurts eert

ni si sesira erutcurts a hcus erehw ecalp nommoc yrev enO .sehcnarb yb detaler era noitamrofni fo smeti.seigolaeneg fo noitagitsevni eht

epyTataDtcartsbA {eert secnatsni A tes fo :stnemele

)1( ytpme ro gnivah a dehsiugnitsid toor tnemele )2( hcae non - toor tnemele gnivah yltcaxe eno tnerap tnemele snoitarepo )(toor )(eerged )k(dlihc } :seert rof ygolonimret cisab emoS

morf demrof era seerT sedon dna segde dellac semitemos era sedoN . secitrev era segdE . dellac semitemos sehcnarb .

gnidulcni seitreporp fo rebmun a evah yam sedoN eulav dna lebal . doohtnerap" dellac si noitaler siht ,eert a nI .rehto hcae ot sedon etaler ot desu era segdE ". egde nA eht sa a sehsilbatse b dna a sedon neewteb }b,a{ tnerap a dellac si b ,oslA .b fo dlihc fo

.a nI .dlihc ot tnerap morf detcerid yllaer era yeht ,senil elpmis sa nward yllausu era segde hguohtlA

pot si siht ,sgniward eert - ot - .mottob noitinifeD lamrofnI : a eert ",toor" sa dehsiugnitsid si hcihw fo eno ,sedon fo noitcelloc a si

.segde yb nwohs si taht )"doohtnerap"( noitaler a htiw gnola noitinifeD lamroF ehT .flesti fo smret ni eert senifed ti taht ni "evisrucer" si noitinifed sihT :

oc" osla si noitinifed .eert a tcurtsnoc ot woh sebircsed ti taht ni "evitcurtsn .1 ".toor" si tI .eert a si edon elgnis A .2 T dna edon a si N esoppuS 1 T , 2 T ,... , k n stoor htiw seert era 1 n , 2 n,... , k eW .ylevitcepser ,

sedon eht fo tnerap eht N gnikam yb T eert wen a tcurtsnoc nac n1 n , 2 n ,... , k si N ,nehT .T dna T fo toor eht 1 T , 2 T ,... , k .seertbus era

seertbus k gnisu detcurtsnoc ,T eert ehT

Page 62: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 26

ygolonimret eroM

rehtie si edon A lanretni a si ti ro fael . A fael .nerdlihc on sah taht edon a si .tnerap eno yltcaxe sah )toor tpecxe( eert a ni edon yrevE ehT edon a fo eerged .sah ti nerdlihc fo rebmun eht si ehT eert a fo eerged .sedon sti fo lla fo eerged mumixam eht si

sleveL dna shtaP

noitinifeD A : htap n sedon fo ecneuqes a si 1 n , 2 n ,... , k n edon taht hcus i n edon fo tnerap eht si 1+i .k =< i =< 1 lla rof

noitinifeD ehT : htgnel fo rebmun eht naht ssel eno( htap eht no segde fo rebmun eht si htap a fo .)sedon

noitinifeD ehT : stnednecsed morf htap emos no era taht sedon eht lla era edon a fo ot edon eht .fael yna

noitinifeD ehT : srotsecna eht ot edon eht morf htap eht no era taht sedon eht lla era edon a fo .toor

noitinifeD ehT : htped a fo htped ehT .edon eht ot toor morf htap eht fo htgnel eht si edon a fo sti dellac semitemos si edon level .

noitinifeD ehT : edon a fo thgieh .fael a ot edon eht morf htap tsegnol eht fo htgnel eht si noitinifeD eht : eert a fo thgieh .toor sti fo thgieh eht si

)slevel( shtped edon gniwohs ,eert lareneg A

:evoba elpmaxe eht nI

.sedon fael era W dna ,V ,U ,Z ,Y sedon ehT .sedon lanretni era X dna ,T ,S ,R sedon ehT .1 si S edon fo eerged ehT .3 si T edon fo eerged ehT .3 si Z edon fo htped ehT .2 si X edon fo htped ehT .2 si S edon fo thgieh ehT .orez si Z edon fo thgieh ehT .3 si R edon fo thgieh ehT .3 si eert eht fo thgieh eht eroferehT .R toor sti fo thgieh eht sa emas eht si eert eht fo thgieh ehT .htap a si X,S,R sedon fo ecneuqes ehT eht yfsitas ton seod ecneuqes eht esuaceb htap a ton si Y,X,R sedon fo ecneuqes ehT

.)X fo tnerap eht ton si R( ytreporp "doohtnerap"

seert fo noitatneserpeR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 26

ygolonimret eroM

rehtie si edon A lanretni a si ti ro fael . A fael .nerdlihc on sah taht edon a si .tnerap eno yltcaxe sah )toor tpecxe( eert a ni edon yrevE ehT edon a fo eerged .sah ti nerdlihc fo rebmun eht si ehT eert a fo eerged .sedon sti fo lla fo eerged mumixam eht si

sleveL dna shtaP

noitinifeD A : htap n sedon fo ecneuqes a si 1 n , 2 n ,... , k n edon taht hcus i n edon fo tnerap eht si 1+i .k =< i =< 1 lla rof

noitinifeD ehT : htgnel fo rebmun eht naht ssel eno( htap eht no segde fo rebmun eht si htap a fo .)sedon

noitinifeD ehT : stnednecsed morf htap emos no era taht sedon eht lla era edon a fo ot edon eht .fael yna

noitinifeD ehT : srotsecna eht ot edon eht morf htap eht no era taht sedon eht lla era edon a fo .toor

noitinifeD ehT : htped a fo htped ehT .edon eht ot toor morf htap eht fo htgnel eht si edon a fo sti dellac semitemos si edon level .

noitinifeD ehT : edon a fo thgieh .fael a ot edon eht morf htap tsegnol eht fo htgnel eht si noitinifeD eht : eert a fo thgieh .toor sti fo thgieh eht si

)slevel( shtped edon gniwohs ,eert lareneg A

:evoba elpmaxe eht nI

.sedon fael era W dna ,V ,U ,Z ,Y sedon ehT .sedon lanretni era X dna ,T ,S ,R sedon ehT .1 si S edon fo eerged ehT .3 si T edon fo eerged ehT .3 si Z edon fo htped ehT .2 si X edon fo htped ehT .2 si S edon fo thgieh ehT .orez si Z edon fo thgieh ehT .3 si R edon fo thgieh ehT .3 si eert eht fo thgieh eht eroferehT .R toor sti fo thgieh eht sa emas eht si eert eht fo thgieh ehT .htap a si X,S,R sedon fo ecneuqes ehT eht yfsitas ton seod ecneuqes eht esuaceb htap a ton si Y,X,R sedon fo ecneuqes ehT

.)X fo tnerap eht ton si R( ytreporp "doohtnerap"

seert fo noitatneserpeR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 26

ygolonimret eroM

rehtie si edon A lanretni a si ti ro fael . A fael .nerdlihc on sah taht edon a si .tnerap eno yltcaxe sah )toor tpecxe( eert a ni edon yrevE ehT edon a fo eerged .sah ti nerdlihc fo rebmun eht si ehT eert a fo eerged .sedon sti fo lla fo eerged mumixam eht si

sleveL dna shtaP

noitinifeD A : htap n sedon fo ecneuqes a si 1 n , 2 n ,... , k n edon taht hcus i n edon fo tnerap eht si 1+i .k =< i =< 1 lla rof

noitinifeD ehT : htgnel fo rebmun eht naht ssel eno( htap eht no segde fo rebmun eht si htap a fo .)sedon

noitinifeD ehT : stnednecsed morf htap emos no era taht sedon eht lla era edon a fo ot edon eht .fael yna

noitinifeD ehT : srotsecna eht ot edon eht morf htap eht no era taht sedon eht lla era edon a fo .toor

noitinifeD ehT : htped a fo htped ehT .edon eht ot toor morf htap eht fo htgnel eht si edon a fo sti dellac semitemos si edon level .

noitinifeD ehT : edon a fo thgieh .fael a ot edon eht morf htap tsegnol eht fo htgnel eht si noitinifeD eht : eert a fo thgieh .toor sti fo thgieh eht si

)slevel( shtped edon gniwohs ,eert lareneg A

:evoba elpmaxe eht nI

.sedon fael era W dna ,V ,U ,Z ,Y sedon ehT .sedon lanretni era X dna ,T ,S ,R sedon ehT .1 si S edon fo eerged ehT .3 si T edon fo eerged ehT .3 si Z edon fo htped ehT .2 si X edon fo htped ehT .2 si S edon fo thgieh ehT .orez si Z edon fo thgieh ehT .3 si R edon fo thgieh ehT .3 si eert eht fo thgieh eht eroferehT .R toor sti fo thgieh eht sa emas eht si eert eht fo thgieh ehT .htap a si X,S,R sedon fo ecneuqes ehT eht yfsitas ton seod ecneuqes eht esuaceb htap a ton si Y,X,R sedon fo ecneuqes ehT

.)X fo tnerap eht ton si R( ytreporp "doohtnerap"

seert fo noitatneserpeR

Page 63: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 36

tsiL .1 noitatneserper

noitatneserper gnilbis thgir dlihc tfel .2

noitatneserpeR .3 eert owt eerged a sa

seerT yraniB 2.5 : noitinifeD fo nerdlihc eht dna 2 yltcaxe fo eerged sah edon hcae hcihw ni eert a si eert yranib A :

.ytpme eb yam edon a fo nerdlihc eht fo emoS ".thgir" dna "tfel" sa dehsiugnitsid era edon hcae noitinifeD lamroF :si eert yranib A :

.1 ro ,ytpme rehtie

.2 .eert yranib a si hcihw fo hcae ,eertbus thgir a dna tfel a sah taht edon a si ti noitinifeD A : eert yranib lluf non 2 yltcaxe sah edon hcae hcihw ni eert yranib a si )TBF( - ytpme

l emas eht no era sevael eht lla dna ,nerdlihc ytpme owt yltcaxe ro nerdlihc siht taht etoN( .leve .)noitinifed txet eht morf sreffid noitinifed

noitinifeD A : eert yranib etelpmoc yam level tsepeed eht taht ,spahrep ,tpecxe TBF a si )TBC(tfel morf dellif si ti ,dellif yletelpmoc ton fI .dellif yletelpmoc eb ton - ot - .thgir

i TBF A eciv ton tub ,TBC a s - .asrev

seerT yraniB fo selpmaxE

.eerT yraniB A nwohs ylticilpxe ton era nerdlihc ytpme eht ,lausu sA .

.eerT yraniB lluF A level ta sedon fo rebmun eht ,TBF a nI i 2 si i .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 36

tsiL .1 noitatneserper

noitatneserper gnilbis thgir dlihc tfel .2

noitatneserpeR .3 eert owt eerged a sa

seerT yraniB 2.5 : noitinifeD fo nerdlihc eht dna 2 yltcaxe fo eerged sah edon hcae hcihw ni eert a si eert yranib A :

.ytpme eb yam edon a fo nerdlihc eht fo emoS ".thgir" dna "tfel" sa dehsiugnitsid era edon hcae noitinifeD lamroF :si eert yranib A :

.1 ro ,ytpme rehtie

.2 .eert yranib a si hcihw fo hcae ,eertbus thgir a dna tfel a sah taht edon a si ti noitinifeD A : eert yranib lluf non 2 yltcaxe sah edon hcae hcihw ni eert yranib a si )TBF( - ytpme

l emas eht no era sevael eht lla dna ,nerdlihc ytpme owt yltcaxe ro nerdlihc siht taht etoN( .leve .)noitinifed txet eht morf sreffid noitinifed

noitinifeD A : eert yranib etelpmoc yam level tsepeed eht taht ,spahrep ,tpecxe TBF a si )TBC(tfel morf dellif si ti ,dellif yletelpmoc ton fI .dellif yletelpmoc eb ton - ot - .thgir

i TBF A eciv ton tub ,TBC a s - .asrev

seerT yraniB fo selpmaxE

.eerT yraniB A nwohs ylticilpxe ton era nerdlihc ytpme eht ,lausu sA .

.eerT yraniB lluF A level ta sedon fo rebmun eht ,TBF a nI i 2 si i .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 36

tsiL .1 noitatneserper

noitatneserper gnilbis thgir dlihc tfel .2

noitatneserpeR .3 eert owt eerged a sa

seerT yraniB 2.5 : noitinifeD fo nerdlihc eht dna 2 yltcaxe fo eerged sah edon hcae hcihw ni eert a si eert yranib A :

.ytpme eb yam edon a fo nerdlihc eht fo emoS ".thgir" dna "tfel" sa dehsiugnitsid era edon hcae noitinifeD lamroF :si eert yranib A :

.1 ro ,ytpme rehtie

.2 .eert yranib a si hcihw fo hcae ,eertbus thgir a dna tfel a sah taht edon a si ti noitinifeD A : eert yranib lluf non 2 yltcaxe sah edon hcae hcihw ni eert yranib a si )TBF( - ytpme

l emas eht no era sevael eht lla dna ,nerdlihc ytpme owt yltcaxe ro nerdlihc siht taht etoN( .leve .)noitinifed txet eht morf sreffid noitinifed

noitinifeD A : eert yranib etelpmoc yam level tsepeed eht taht ,spahrep ,tpecxe TBF a si )TBC(tfel morf dellif si ti ,dellif yletelpmoc ton fI .dellif yletelpmoc eb ton - ot - .thgir

i TBF A eciv ton tub ,TBC a s - .asrev

seerT yraniB fo selpmaxE

.eerT yraniB A nwohs ylticilpxe ton era nerdlihc ytpme eht ,lausu sA .

.eerT yraniB lluF A level ta sedon fo rebmun eht ,TBF a nI i 2 si i .

Page 64: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 46

.eerT yraniB etelpmoC A

yraniB etelpmoC a toN .eerT si evoba eert ehT ton eht esuaceb TBC atfel morf dellif ton si level tsepeed - ot - .thgir

seitreporP

eert lluF non eht lla dna ,level emas eht ta sevael eht lla htiw eert A - .eerged emas eht gnivah sevael

eerT etelpmoC .deteled era stnemele ’tsal‘ eht hcihw ni eert lluf A

leveL h sah eert lluf a fo dh-1 .sedon

tsrif ehT h evah eert lluf a fo slevel .sedon

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 46

.eerT yraniB etelpmoC A

yraniB etelpmoC a toN .eerT si evoba eert ehT ton eht esuaceb TBC atfel morf dellif ton si level tsepeed - ot - .thgir

seitreporP

eert lluF non eht lla dna ,level emas eht ta sevael eht lla htiw eert A - .eerged emas eht gnivah sevael

eerT etelpmoC .deteled era stnemele ’tsal‘ eht hcihw ni eert lluf A

leveL h sah eert lluf a fo dh-1 .sedon

tsrif ehT h evah eert lluf a fo slevel .sedon

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 46

.eerT yraniB etelpmoC A

yraniB etelpmoC a toN .eerT si evoba eert ehT ton eht esuaceb TBC atfel morf dellif ton si level tsepeed - ot - .thgir

seitreporP

eert lluF non eht lla dna ,level emas eht ta sevael eht lla htiw eert A - .eerged emas eht gnivah sevael

eerT etelpmoC .deteled era stnemele ’tsal‘ eht hcihw ni eert lluf A

leveL h sah eert lluf a fo dh-1 .sedon

tsrif ehT h evah eert lluf a fo slevel .sedon

Page 65: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 56

thgieh fo eert A h eerged dna d tsom ta sah dh - stnemele 1

snoitatneserpeR

.1 sretniop k dna dleif atad a fo gnitsisnoc sedoN

.2 a dna ,dlihc tsrif eht ot retniop a :sretniop owt dna dleif atad w fo gnitsisnoc sedoN .gnilbis txen eht ot retniop

.3 eerged fo eert A k eerged fo eert etelpmoc a gnidloh rof yarra na semussa k ytpme htiw , .stnemele gnissim rof dengissa sllec

3.5 yraniB eert slasrevarT :

eht si yltneuqerf sesira taht noiton enO .seert no mrofrep ot tnaw netfo ew taht snoitarepo ynam era erehT raenil a secudorp lasrevart lluf A .ecno yltcaxe eert eht ni edon hcae gnitisiv ro eert a gnisrevart fo aedi

itamrofni eht rof redro yranib a gnisrevart nehW .lufesu dna railimaf eb yam redro raenil sihT .eert a ni no tel ew fI .noihsaf emas eht ni seertbus sti dna edon hcae taert ot tnaw ew eert R ,D ,L gnivom rof dnats

reht neht edon a ta nehw thgir gnivom dna ,atad eht gnitnirp ,tfel fo snoitanibmoc elbissop xis era e :lasrevart ,LDR ,LRD ,RLD ,DRL ,RDL dna DLR erofeb tfel esrevart ew taht noitnevnoc eht tpoda ew fI .

:niamer slasrevart eerht ylno neht thgir DRL ,RDL dna RLD ,redroni seman eht ngissa ew eseht oT . gnicudorp dna slasrevart eseht neewteb ecnednopserroc larutan a si ereht esuaceb redroerp dna redrotsop

.noisserpxe na fo smrof xiferp dna xiftsop ,xifni eht

redro leveL

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 56

thgieh fo eert A h eerged dna d tsom ta sah dh - stnemele 1

snoitatneserpeR

.1 sretniop k dna dleif atad a fo gnitsisnoc sedoN

.2 a dna ,dlihc tsrif eht ot retniop a :sretniop owt dna dleif atad w fo gnitsisnoc sedoN .gnilbis txen eht ot retniop

.3 eerged fo eert A k eerged fo eert etelpmoc a gnidloh rof yarra na semussa k ytpme htiw , .stnemele gnissim rof dengissa sllec

3.5 yraniB eert slasrevarT :

eht si yltneuqerf sesira taht noiton enO .seert no mrofrep ot tnaw netfo ew taht snoitarepo ynam era erehT raenil a secudorp lasrevart lluf A .ecno yltcaxe eert eht ni edon hcae gnitisiv ro eert a gnisrevart fo aedi

itamrofni eht rof redro yranib a gnisrevart nehW .lufesu dna railimaf eb yam redro raenil sihT .eert a ni no tel ew fI .noihsaf emas eht ni seertbus sti dna edon hcae taert ot tnaw ew eert R ,D ,L gnivom rof dnats

reht neht edon a ta nehw thgir gnivom dna ,atad eht gnitnirp ,tfel fo snoitanibmoc elbissop xis era e :lasrevart ,LDR ,LRD ,RLD ,DRL ,RDL dna DLR erofeb tfel esrevart ew taht noitnevnoc eht tpoda ew fI .

:niamer slasrevart eerht ylno neht thgir DRL ,RDL dna RLD ,redroni seman eht ngissa ew eseht oT . gnicudorp dna slasrevart eseht neewteb ecnednopserroc larutan a si ereht esuaceb redroerp dna redrotsop

.noisserpxe na fo smrof xiferp dna xiftsop ,xifni eht

redro leveL

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 56

thgieh fo eert A h eerged dna d tsom ta sah dh - stnemele 1

snoitatneserpeR

.1 sretniop k dna dleif atad a fo gnitsisnoc sedoN

.2 a dna ,dlihc tsrif eht ot retniop a :sretniop owt dna dleif atad w fo gnitsisnoc sedoN .gnilbis txen eht ot retniop

.3 eerged fo eert A k eerged fo eert etelpmoc a gnidloh rof yarra na semussa k ytpme htiw , .stnemele gnissim rof dengissa sllec

3.5 yraniB eert slasrevarT :

eht si yltneuqerf sesira taht noiton enO .seert no mrofrep ot tnaw netfo ew taht snoitarepo ynam era erehT raenil a secudorp lasrevart lluf A .ecno yltcaxe eert eht ni edon hcae gnitisiv ro eert a gnisrevart fo aedi

itamrofni eht rof redro yranib a gnisrevart nehW .lufesu dna railimaf eb yam redro raenil sihT .eert a ni no tel ew fI .noihsaf emas eht ni seertbus sti dna edon hcae taert ot tnaw ew eert R ,D ,L gnivom rof dnats

reht neht edon a ta nehw thgir gnivom dna ,atad eht gnitnirp ,tfel fo snoitanibmoc elbissop xis era e :lasrevart ,LDR ,LRD ,RLD ,DRL ,RDL dna DLR erofeb tfel esrevart ew taht noitnevnoc eht tpoda ew fI .

:niamer slasrevart eerht ylno neht thgir DRL ,RDL dna RLD ,redroni seman eht ngissa ew eseht oT . gnicudorp dna slasrevart eseht neewteb ecnednopserroc larutan a si ereht esuaceb redroerp dna redrotsop

.noisserpxe na fo smrof xiferp dna xiftsop ,xifni eht

redro leveL

Page 66: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 66

x =: )(toor (fi x ) eueuq )x(

(elihw ueuq e ton ytpme {) x =: )(eueuqed )(tisiv ;1=i (elihw i =< )(eerged {) (eueuq )i(dlihc ) } } redroerP

erudecorp {)x(redroerp )x(tisiv ;1=i (elihw i =< )(eerged {) (redroerp )i(dlihc ) } } redrotsoP

erudecorp {)x(redrotsop ;1=i (elihw i =< )(eerged {) (redrotsop )i(dlihc ) } )x(tisiv }

redronI

.seert yranib rof tsuj lufgninaeM

erudecorp {)x(redroni (fi )x(rof_dlihc_tfel ) { (redroni )x(dlihc_tfel ) } )x(tisiv (fi )x(rof_dlihc_thgir ) { (redroni )x(dlihc_thgir ) } }

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 66

x =: )(toor (fi x ) eueuq )x(

(elihw ueuq e ton ytpme {) x =: )(eueuqed )(tisiv ;1=i (elihw i =< )(eerged {) (eueuq )i(dlihc ) } } redroerP

erudecorp {)x(redroerp )x(tisiv ;1=i (elihw i =< )(eerged {) (redroerp )i(dlihc ) } } redrotsoP

erudecorp {)x(redrotsop ;1=i (elihw i =< )(eerged {) (redrotsop )i(dlihc ) } )x(tisiv }

redronI

.seert yranib rof tsuj lufgninaeM

erudecorp {)x(redroni (fi )x(rof_dlihc_tfel ) { (redroni )x(dlihc_tfel ) } )x(tisiv (fi )x(rof_dlihc_thgir ) { (redroni )x(dlihc_thgir ) } }

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 66

x =: )(toor (fi x ) eueuq )x(

(elihw ueuq e ton ytpme {) x =: )(eueuqed )(tisiv ;1=i (elihw i =< )(eerged {) (eueuq )i(dlihc ) } } redroerP

erudecorp {)x(redroerp )x(tisiv ;1=i (elihw i =< )(eerged {) (redroerp )i(dlihc ) } } redrotsoP

erudecorp {)x(redrotsop ;1=i (elihw i =< )(eerged {) (redrotsop )i(dlihc ) } )x(tisiv }

redronI

.seert yranib rof tsuj lufgninaeM

erudecorp {)x(redroni (fi )x(rof_dlihc_tfel ) { (redroni )x(dlihc_tfel ) } )x(tisiv (fi )x(rof_dlihc_thgir ) { (redroni )x(dlihc_thgir ) } }

Page 67: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 76

. stnemele fo rebmun eht tnuoc ,thgieh eht enimreted :’tisiv‘ rof segasU

seert yraniB dedaerhT .4.5 : sknil llun erom era ereht taht eciton ew ,eert yranib yna fo noitatneserper deknil eht ta ylluferac kool ew fI

era ereht ,erofeb was ew sA .sretniop lautca naht n 2 dna sknil llun 1 + n ekam ot yaw revelc A .sknil latotived neeb sah sknil llun eseht fo esu llun eht ecalper ot si aedi riehT .notnrohT .C dna silreP .J .A yb des

(DLIHCR eht fI .eert eht ni sedon rehto ot ,sdaerht dellac ,sretniop yb sknil P ,orez ot lauqe yllamron si ) ti ecalper lliw ew ehw P retfa detnirp eb dluow hcihw edon eht ot retniop a yb ni eert eht gnisrevart n

redroni edon ta knil DLIHCL llun A . P decalper si sedecerp yletaidemmi hcihw edon eht ot retniop a ybredroni ni P edon .

eert ehT T esrevart ew fI .sdaerht yb decalper neeb evah hcihw sknil llun 01 dna sedon 9 sah T redroni ni eht redro eht ni detisiv eb lliw sedon G C F A E B I D H edon elpmaxe roF . E daerht rossecederp a sah

ot stniop hcihw daerht rosseccus a dna B ot stniop hcihw A .

.sretniop lamron dna sdaerht neewteb hsiugnitsid ot elba eb tsum ew noitatneserper yromem eht nI si sihT .TIBR dna TIBL sdleif tib eno artxe owt gnidda yb enod

(TIBL P (DLIHCL fi 1= ) P retniop lamron a si ) (TIBL P (DLIHCL fi 0 = ) P daerht a si ) (TIBR P (DLIHCR fi 1 = ) P retniop lamron a si ) (TIBR P (DLIHCR fi 0 = ) P daerht a si )

.5.5 spaeH A paeh gniredro na htiw eert etelpmoc a si - .tnadnecsed sti dna edon hcae neewteb gnidloh R noitaler

rof selpmaxE R rellams : - reggib ,naht - naht

noitpmussA ,swollof tahw nI : R reggib‘ noitaler eht si - .2 eerged evah seert eht dna ,’naht

paeH paeh a toN

tnemelE na gniddA

.1 eert eht ot edon a ddA

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 76

. stnemele fo rebmun eht tnuoc ,thgieh eht enimreted :’tisiv‘ rof segasU

seert yraniB dedaerhT .4.5 : sknil llun erom era ereht taht eciton ew ,eert yranib yna fo noitatneserper deknil eht ta ylluferac kool ew fI

era ereht ,erofeb was ew sA .sretniop lautca naht n 2 dna sknil llun 1 + n ekam ot yaw revelc A .sknil latotived neeb sah sknil llun eseht fo esu llun eht ecalper ot si aedi riehT .notnrohT .C dna silreP .J .A yb des

(DLIHCR eht fI .eert eht ni sedon rehto ot ,sdaerht dellac ,sretniop yb sknil P ,orez ot lauqe yllamron si ) ti ecalper lliw ew ehw P retfa detnirp eb dluow hcihw edon eht ot retniop a yb ni eert eht gnisrevart n

redroni edon ta knil DLIHCL llun A . P decalper si sedecerp yletaidemmi hcihw edon eht ot retniop a ybredroni ni P edon .

eert ehT T esrevart ew fI .sdaerht yb decalper neeb evah hcihw sknil llun 01 dna sedon 9 sah T redroni ni eht redro eht ni detisiv eb lliw sedon G C F A E B I D H edon elpmaxe roF . E daerht rossecederp a sah

ot stniop hcihw daerht rosseccus a dna B ot stniop hcihw A .

.sretniop lamron dna sdaerht neewteb hsiugnitsid ot elba eb tsum ew noitatneserper yromem eht nI si sihT .TIBR dna TIBL sdleif tib eno artxe owt gnidda yb enod

(TIBL P (DLIHCL fi 1= ) P retniop lamron a si ) (TIBL P (DLIHCL fi 0 = ) P daerht a si ) (TIBR P (DLIHCR fi 1 = ) P retniop lamron a si ) (TIBR P (DLIHCR fi 0 = ) P daerht a si )

.5.5 spaeH A paeh gniredro na htiw eert etelpmoc a si - .tnadnecsed sti dna edon hcae neewteb gnidloh R noitaler

rof selpmaxE R rellams : - reggib ,naht - naht

noitpmussA ,swollof tahw nI : R reggib‘ noitaler eht si - .2 eerged evah seert eht dna ,’naht

paeH paeh a toN

tnemelE na gniddA

.1 eert eht ot edon a ddA

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 76

. stnemele fo rebmun eht tnuoc ,thgieh eht enimreted :’tisiv‘ rof segasU

seert yraniB dedaerhT .4.5 : sknil llun erom era ereht taht eciton ew ,eert yranib yna fo noitatneserper deknil eht ta ylluferac kool ew fI

era ereht ,erofeb was ew sA .sretniop lautca naht n 2 dna sknil llun 1 + n ekam ot yaw revelc A .sknil latotived neeb sah sknil llun eseht fo esu llun eht ecalper ot si aedi riehT .notnrohT .C dna silreP .J .A yb des

(DLIHCR eht fI .eert eht ni sedon rehto ot ,sdaerht dellac ,sretniop yb sknil P ,orez ot lauqe yllamron si ) ti ecalper lliw ew ehw P retfa detnirp eb dluow hcihw edon eht ot retniop a yb ni eert eht gnisrevart n

redroni edon ta knil DLIHCL llun A . P decalper si sedecerp yletaidemmi hcihw edon eht ot retniop a ybredroni ni P edon .

eert ehT T esrevart ew fI .sdaerht yb decalper neeb evah hcihw sknil llun 01 dna sedon 9 sah T redroni ni eht redro eht ni detisiv eb lliw sedon G C F A E B I D H edon elpmaxe roF . E daerht rossecederp a sah

ot stniop hcihw daerht rosseccus a dna B ot stniop hcihw A .

.sretniop lamron dna sdaerht neewteb hsiugnitsid ot elba eb tsum ew noitatneserper yromem eht nI si sihT .TIBR dna TIBL sdleif tib eno artxe owt gnidda yb enod

(TIBL P (DLIHCL fi 1= ) P retniop lamron a si ) (TIBL P (DLIHCL fi 0 = ) P daerht a si ) (TIBR P (DLIHCR fi 1 = ) P retniop lamron a si ) (TIBR P (DLIHCR fi 0 = ) P daerht a si )

.5.5 spaeH A paeh gniredro na htiw eert etelpmoc a si - .tnadnecsed sti dna edon hcae neewteb gnidloh R noitaler

rof selpmaxE R rellams : - reggib ,naht - naht

noitpmussA ,swollof tahw nI : R reggib‘ noitaler eht si - .2 eerged evah seert eht dna ,’naht

paeH paeh a toN

tnemelE na gniddA

.1 eert eht ot edon a ddA

Page 68: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 86

.2 era yeht fi ,nwod noitisop eno edon wen eht ot toor eht morf htap eht ni stnemele eht evoM tnemele wen eht naht rellams

tnemele wen 4 7 9

eert deifidom

.3 edon tnacav eht ot tnemele wen eht tresnI

.4 fo eert etelpmoc A n htped sah sedon gol n si ytixelpmoc emit eht ecneh , O gol( n )

tnemelE na gniteleD

.1 .eulav sti gnivas elihw edon tsal eht eteled dna ,edon toor eht morf eulav eht eteleD

erofeb retfa

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 86

.2 era yeht fi ,nwod noitisop eno edon wen eht ot toor eht morf htap eht ni stnemele eht evoM tnemele wen eht naht rellams

tnemele wen 4 7 9

eert deifidom

.3 edon tnacav eht ot tnemele wen eht tresnI

.4 fo eert etelpmoc A n htped sah sedon gol n si ytixelpmoc emit eht ecneh , O gol( n )

tnemelE na gniteleD

.1 .eulav sti gnivas elihw edon tsal eht eteled dna ,edon toor eht morf eulav eht eteleD

erofeb retfa

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 86

.2 era yeht fi ,nwod noitisop eno edon wen eht ot toor eht morf htap eht ni stnemele eht evoM tnemele wen eht naht rellams

tnemele wen 4 7 9

eert deifidom

.3 edon tnacav eht ot tnemele wen eht tresnI

.4 fo eert etelpmoc A n htped sah sedon gol n si ytixelpmoc emit eht ecneh , O gol( n )

tnemelE na gniteleD

.1 .eulav sti gnivas elihw edon tsal eht eteled dna ,edon toor eht morf eulav eht eteleD

erofeb retfa

Page 69: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 96

.2 tnacav eht otni pu evom ,edon tnacav eht fo dlihc a naht rellams si eulav devas eht sa gnol sA .nerdlihc eht fo eulav tsegral eht edon

.3 edon tnacav eht otni eulav devas eht tresnI

.4 si ytixelpmoc emit ehT O gol( n )

noitazilaitinI :

ecroF eturB fo ecneuqes a neviG n seulav e1, e ,... n eht no eludom noitresni eht esu yldetaeper , n .seulav nevig

leveL h 2 tsom ta sah eert etelpmoc a ni h-1 = O 2( n stnemele ) 1 sleveL h ,... , - 2 evah 1 0 2 + 1 + 2 + h-2 = O 2( h stnemele ) seriuqer tnemele hcaE O gol( n seriuqer noitazilaitini ecrof eturb ,ecneH .emit ) O(n gol n )

.emit

tneiciffE

eht tresnI n stnemele e1 e ,... , n eert etelpmoc a otni

eertbus eht paeh a otni ezinagroer ,toor eht ta gnidne dna eno tsal eht morf gnitrats ,edon hcae roF htiw tnemele wen eht gnignahcretni yb demrofrep si noitazinagroer ehT .nevig si edon toor esohw

etaerg si tnemele wen eht litnu ,eulav retaerg fo dlihc eht .nerdlihc sti naht r

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 96

.2 tnacav eht otni pu evom ,edon tnacav eht fo dlihc a naht rellams si eulav devas eht sa gnol sA .nerdlihc eht fo eulav tsegral eht edon

.3 edon tnacav eht otni eulav devas eht tresnI

.4 si ytixelpmoc emit ehT O gol( n )

noitazilaitinI :

ecroF eturB fo ecneuqes a neviG n seulav e1, e ,... n eht no eludom noitresni eht esu yldetaeper , n .seulav nevig

leveL h 2 tsom ta sah eert etelpmoc a ni h-1 = O 2( n stnemele ) 1 sleveL h ,... , - 2 evah 1 0 2 + 1 + 2 + h-2 = O 2( h stnemele ) seriuqer tnemele hcaE O gol( n seriuqer noitazilaitini ecrof eturb ,ecneH .emit ) O(n gol n )

.emit

tneiciffE

eht tresnI n stnemele e1 e ,... , n eert etelpmoc a otni

eertbus eht paeh a otni ezinagroer ,toor eht ta gnidne dna eno tsal eht morf gnitrats ,edon hcae roF htiw tnemele wen eht gnignahcretni yb demrofrep si noitazinagroer ehT .nevig si edon toor esohw

etaerg si tnemele wen eht litnu ,eulav retaerg fo dlihc eht .nerdlihc sti naht r

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 96

.2 tnacav eht otni pu evom ,edon tnacav eht fo dlihc a naht rellams si eulav devas eht sa gnol sA .nerdlihc eht fo eulav tsegral eht edon

.3 edon tnacav eht otni eulav devas eht tresnI

.4 si ytixelpmoc emit ehT O gol( n )

noitazilaitinI :

ecroF eturB fo ecneuqes a neviG n seulav e1, e ,... n eht no eludom noitresni eht esu yldetaeper , n .seulav nevig

leveL h 2 tsom ta sah eert etelpmoc a ni h-1 = O 2( n stnemele ) 1 sleveL h ,... , - 2 evah 1 0 2 + 1 + 2 + h-2 = O 2( h stnemele ) seriuqer tnemele hcaE O gol( n seriuqer noitazilaitini ecrof eturb ,ecneH .emit ) O(n gol n )

.emit

tneiciffE

eht tresnI n stnemele e1 e ,... , n eert etelpmoc a otni

eertbus eht paeh a otni ezinagroer ,toor eht ta gnidne dna eno tsal eht morf gnitrats ,edon hcae roF htiw tnemele wen eht gnignahcretni yb demrofrep si noitazinagroer ehT .nevig si edon toor esohw

etaerg si tnemele wen eht litnu ,eulav retaerg fo dlihc eht .nerdlihc sti naht r

Page 70: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 07

si ytixelpmoc emit ehT O 0( * ( /n 1 + )2 * ( /n 2 + )4 * ( /n + )8 gol( + n ) * = )1 O(n 0( 2-1 1 + 2-2 2 + 2-3 + gol( + n ) 2- gol n = )) O(n )

.sdloh seitilauqe gniwollof eht ecnis k 1 = ( k - 2)1 -k [2= k 1 = ( k - 2)1 -k ] - [ k 1 = ( k - 2)1 -

k [= ] k 1 = k2-k ] - [ k 1 = ( k - 2)1 -k = ] k 1 = [ k - ( k - 2])1 -k = k 1 = 2-k 1=

snoitacilppA :

eueuQ ytiroirP gniredro nevig a ot gnidrocca deteled era stnemele hcihw ni tes cimanyd A - .noitalertroS paeH ( tes nevig eht morf paeh a dliuB O(n eht morf stnemele eht evomer yldetaeper neht ,emit ))

( paeh O(n gol n .))

.6.5 SNOITSEUQ DEDNEMMOCER 1 rt yranib a tcurtsnoC . 3(+6(( : rof ee - )3+2^)5*)2

2 .seert yranib dedaerht ni tfel dna ni thgir nialpxE ?eert yranib dedaerht si tahW .

eert a enifeD .3 .eert yranib ot eert lareneg trevnoc ot erudecorp eht etirW .

toor ,sevael ,edon eht fo eerged enifeD .4

lanretni enifeD .5 eert a fo thgieh dna htped ,edon tnerap ,sedon

eert yranib a fo seitreporp eht etatS .6

seuqinhcet lasrevart eert yranib tnereffid eht era tahW ?lasrevart eert yranib yb tnaem si tahW .7

yranib fo noitatneserper raenil fo tiremed & stirem eht etatS .8 .seert

thgir enifeD .9 - tfel & eert dedaerht ni - eert dedaerht ni

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 07

si ytixelpmoc emit ehT O 0( * ( /n 1 + )2 * ( /n 2 + )4 * ( /n + )8 gol( + n ) * = )1 O(n 0( 2-1 1 + 2-2 2 + 2-3 + gol( + n ) 2- gol n = )) O(n )

.sdloh seitilauqe gniwollof eht ecnis k 1 = ( k - 2)1 -k [2= k 1 = ( k - 2)1 -k ] - [ k 1 = ( k - 2)1 -

k [= ] k 1 = k2-k ] - [ k 1 = ( k - 2)1 -k = ] k 1 = [ k - ( k - 2])1 -k = k 1 = 2-k 1=

snoitacilppA :

eueuQ ytiroirP gniredro nevig a ot gnidrocca deteled era stnemele hcihw ni tes cimanyd A - .noitalertroS paeH ( tes nevig eht morf paeh a dliuB O(n eht morf stnemele eht evomer yldetaeper neht ,emit ))

( paeh O(n gol n .))

.6.5 SNOITSEUQ DEDNEMMOCER 1 rt yranib a tcurtsnoC . 3(+6(( : rof ee - )3+2^)5*)2

2 .seert yranib dedaerht ni tfel dna ni thgir nialpxE ?eert yranib dedaerht si tahW .

eert a enifeD .3 .eert yranib ot eert lareneg trevnoc ot erudecorp eht etirW .

toor ,sevael ,edon eht fo eerged enifeD .4

lanretni enifeD .5 eert a fo thgieh dna htped ,edon tnerap ,sedon

eert yranib a fo seitreporp eht etatS .6

seuqinhcet lasrevart eert yranib tnereffid eht era tahW ?lasrevart eert yranib yb tnaem si tahW .7

yranib fo noitatneserper raenil fo tiremed & stirem eht etatS .8 .seert

thgir enifeD .9 - tfel & eert dedaerht ni - eert dedaerht ni

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 07

si ytixelpmoc emit ehT O 0( * ( /n 1 + )2 * ( /n 2 + )4 * ( /n + )8 gol( + n ) * = )1 O(n 0( 2-1 1 + 2-2 2 + 2-3 + gol( + n ) 2- gol n = )) O(n )

.sdloh seitilauqe gniwollof eht ecnis k 1 = ( k - 2)1 -k [2= k 1 = ( k - 2)1 -k ] - [ k 1 = ( k - 2)1 -

k [= ] k 1 = k2-k ] - [ k 1 = ( k - 2)1 -k = ] k 1 = [ k - ( k - 2])1 -k = k 1 = 2-k 1=

snoitacilppA :

eueuQ ytiroirP gniredro nevig a ot gnidrocca deteled era stnemele hcihw ni tes cimanyd A - .noitalertroS paeH ( tes nevig eht morf paeh a dliuB O(n eht morf stnemele eht evomer yldetaeper neht ,emit ))

( paeh O(n gol n .))

.6.5 SNOITSEUQ DEDNEMMOCER 1 rt yranib a tcurtsnoC . 3(+6(( : rof ee - )3+2^)5*)2

2 .seert yranib dedaerht ni tfel dna ni thgir nialpxE ?eert yranib dedaerht si tahW .

eert a enifeD .3 .eert yranib ot eert lareneg trevnoc ot erudecorp eht etirW .

toor ,sevael ,edon eht fo eerged enifeD .4

lanretni enifeD .5 eert a fo thgieh dna htped ,edon tnerap ,sedon

eert yranib a fo seitreporp eht etatS .6

seuqinhcet lasrevart eert yranib tnereffid eht era tahW ?lasrevart eert yranib yb tnaem si tahW .7

yranib fo noitatneserper raenil fo tiremed & stirem eht etatS .8 .seert

thgir enifeD .9 - tfel & eert dedaerht ni - eert dedaerht ni

Page 71: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 17

TINU – 6 : SEERT – SHPARG ,2

noitcudortnI

eht evlos ot meht desu reluE nehw 6371 ot kcab setad shparg fo esu eht fo ecnedive dedrocer tsrif ehTfo emoS.melborp egdirb grebsgineoK lacissalc won lacirtcele fo sisylana :era shparg fo snoitacilppa eht

,sdnuopmoc lacimehc fo noitacifitnedi ,gninnalp tcejorp fo sisylana ,setuor tsetrohs gnidnif ,stiucricthgim ti ,deednI .cte ,secneics laicos ,scitsiugnil ,scitenrebyc ,sciteneg ,scinahcem lacitsitats dias eb llew

.desu ylediw tsom eht era shparg ,serutcurts lacitamehtam lla fo taht

.hparg s'reluE dna grebsgineoK ni lagerP revir eht fo noitceS 1.6 erugiF

ygolonimreT dna snoitinifeD

,hparg A G stes owt fo stsisnoc , V dna E . V non etinif a si - tes ytpme fo E .secitrev fo sriap fo tes a si dellac era sriap eseht ,secitrev segde . V(G dna ) E(G hparg fo segde dna secitrev fo stes eht tneserper lliw )

G .

etirw osla lliw eW G ( = E,V .hparg a tneserper ot )

na nI hparg detceridnu itneserper secitrev fo riap eht ( sriap eht ,suhT . deredronu si egde yna gn v1 , v2 )( dna v2 , v1 .egde emas eht tneserper )

a nI detcerid hparg ( riap detcerid a yb detneserper si egde hcae v1 , v2 .) v1 eht si liat dna v2 eht daeh eht fo< eroferehT .egde v2 , v1 < dna > v1 , v2> shparg eerht swohs 2.6 erugiF .segde tnereffid owt tneserper G1 , G2

dna G3.

Page 72: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 27

.shparg elpmas eerhT 2.6 erugiF

shparg ehT G1 dna G2 .detceridnu era G3 .hparg detcerid a si

V (G1 ;}4,3,2,1{ = ) E(G1 })4,3(,)4,2(,)3,2(,)4,1(,)3,1(,)2,1({ = )

V (G2 ;}7,6,5,4,3,2,1{ = ) E(G2 })7,3(,)6,3(,)5,2(,)4,2(,)3,1(,)2,1({ = )

V (G3 ;}3,2,1{ = ) E(G3 .}>3,2< ,>1,2< ,>2,1<{ = )

hparg ehT .daeh eht ot liat eht morf worra na htiw nward era hparg detcerid a fo segde eht taht etoN G2 si shparg eht elihw eert a osla G1 a dn G3 ,shparg fo esac laiceps a sa denifed eb nac seerT .ton era

ecnis ,noitidda nI E(G siht nehW .egde emas eht fo secnerrucco elpitlum evah ton yam hparg a ,tes a si )lum a sa ot derrefer si tcejbo atad gnitluser eht ,hparg a morf devomer si noitcirtser atad ehT .hpargit

.hparg a ton si hcihw hpargitlum a si 3.6 erugif fo tcejbo

( sriap deredronu tcnitsid fo rebmun ehT vi,vj htiw ) vi vj htiw hparg a ni n si secitrev n(n - si sihT .2/)1 yna ni segde fo rebmun mumixam eht n .hparg detceridnu xetrev

nA n yltcaxe htiw hparg detceridnu xetrev n(n - eb ot dias si segde 2/)1 G .etelpmoc 1 etelpmoc eht si elihw secitrev 4 no hparg G2 dna G3 no hparg detcerid a fo esac eht nI .shparg etelpmoc ton era n secitrev

si segde fo rebmun mumixam eht n(n - .)1

( fI v1,v2 ni egde na si ) E(G secitrev eht yas llahs ew neht ,) v1 dna v2 era tnecajda ( egde eht taht dna v1,v2 ) si tnedicni secitrev no v1 dna v2 ni 2 xetrev ot tnecajda secitrev ehT . G2 tnedicni segde ehT .1 dna 5 ,4 era

ni 3 xetrev no G2 )7,3( dna )6,3( ,)3,1( era < fI . v1,v2 xetrev neht ,egde detcerid a si > v1 eb ot dias eb lliwtnecajda ot v2 elihw v2 si morf tnecajda v1 < egde ehT . v1,v2 ot tnedicni si > v1 dna v2 nI . G3 segde eht

.>3,2< dna >1,2< ,>2,1< era 2 xetrev ot tnedicni

hpargitlum a fo elpmaxE 3.6 erugiF .hparg a ton si taht

A hpargbus fo G hparg a si 'G taht hcus V( 'G ) V(G dna ) E( 'G ) E(G fo emos swohs 4.6 erugiF .) fo shpargbus eht G1 dna G3.

A htap xetrev morf vp xetrev ot vq hparg ni G secitrev fo ecneuqes a si vp,vi1,vi2 ,... , v ni ,vq taht hcus(vp,vi1 (,) vi1,vi2 (,... ,) v ni ,vq ni segde era ) E(G fI .) 'G < fo stsisnoc htap eht neht detcerid si vp,vi1 <,> vi,vi2 ,>

<,... v ni ,vq ni segde ,> E( 'G .)

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 27

.shparg elpmas eerhT 2.6 erugiF

shparg ehT G1 dna G2 .detceridnu era G3 .hparg detcerid a si

V (G1 ;}4,3,2,1{ = ) E(G1 })4,3(,)4,2(,)3,2(,)4,1(,)3,1(,)2,1({ = )

V (G2 ;}7,6,5,4,3,2,1{ = ) E(G2 })7,3(,)6,3(,)5,2(,)4,2(,)3,1(,)2,1({ = )

V (G3 ;}3,2,1{ = ) E(G3 .}>3,2< ,>1,2< ,>2,1<{ = )

hparg ehT .daeh eht ot liat eht morf worra na htiw nward era hparg detcerid a fo segde eht taht etoN G2 si shparg eht elihw eert a osla G1 a dn G3 ,shparg fo esac laiceps a sa denifed eb nac seerT .ton era

ecnis ,noitidda nI E(G siht nehW .egde emas eht fo secnerrucco elpitlum evah ton yam hparg a ,tes a si )lum a sa ot derrefer si tcejbo atad gnitluser eht ,hparg a morf devomer si noitcirtser atad ehT .hpargit

.hparg a ton si hcihw hpargitlum a si 3.6 erugif fo tcejbo

( sriap deredronu tcnitsid fo rebmun ehT vi,vj htiw ) vi vj htiw hparg a ni n si secitrev n(n - si sihT .2/)1 yna ni segde fo rebmun mumixam eht n .hparg detceridnu xetrev

nA n yltcaxe htiw hparg detceridnu xetrev n(n - eb ot dias si segde 2/)1 G .etelpmoc 1 etelpmoc eht si elihw secitrev 4 no hparg G2 dna G3 no hparg detcerid a fo esac eht nI .shparg etelpmoc ton era n secitrev

si segde fo rebmun mumixam eht n(n - .)1

( fI v1,v2 ni egde na si ) E(G secitrev eht yas llahs ew neht ,) v1 dna v2 era tnecajda ( egde eht taht dna v1,v2 ) si tnedicni secitrev no v1 dna v2 ni 2 xetrev ot tnecajda secitrev ehT . G2 tnedicni segde ehT .1 dna 5 ,4 era

ni 3 xetrev no G2 )7,3( dna )6,3( ,)3,1( era < fI . v1,v2 xetrev neht ,egde detcerid a si > v1 eb ot dias eb lliwtnecajda ot v2 elihw v2 si morf tnecajda v1 < egde ehT . v1,v2 ot tnedicni si > v1 dna v2 nI . G3 segde eht

.>3,2< dna >1,2< ,>2,1< era 2 xetrev ot tnedicni

hpargitlum a fo elpmaxE 3.6 erugiF .hparg a ton si taht

A hpargbus fo G hparg a si 'G taht hcus V( 'G ) V(G dna ) E( 'G ) E(G fo emos swohs 4.6 erugiF .) fo shpargbus eht G1 dna G3.

A htap xetrev morf vp xetrev ot vq hparg ni G secitrev fo ecneuqes a si vp,vi1,vi2 ,... , v ni ,vq taht hcus(vp,vi1 (,) vi1,vi2 (,... ,) v ni ,vq ni segde era ) E(G fI .) 'G < fo stsisnoc htap eht neht detcerid si vp,vi1 <,> vi,vi2 ,>

<,... v ni ,vq ni segde ,> E( 'G .)

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 27

.shparg elpmas eerhT 2.6 erugiF

shparg ehT G1 dna G2 .detceridnu era G3 .hparg detcerid a si

V (G1 ;}4,3,2,1{ = ) E(G1 })4,3(,)4,2(,)3,2(,)4,1(,)3,1(,)2,1({ = )

V (G2 ;}7,6,5,4,3,2,1{ = ) E(G2 })7,3(,)6,3(,)5,2(,)4,2(,)3,1(,)2,1({ = )

V (G3 ;}3,2,1{ = ) E(G3 .}>3,2< ,>1,2< ,>2,1<{ = )

hparg ehT .daeh eht ot liat eht morf worra na htiw nward era hparg detcerid a fo segde eht taht etoN G2 si shparg eht elihw eert a osla G1 a dn G3 ,shparg fo esac laiceps a sa denifed eb nac seerT .ton era

ecnis ,noitidda nI E(G siht nehW .egde emas eht fo secnerrucco elpitlum evah ton yam hparg a ,tes a si )lum a sa ot derrefer si tcejbo atad gnitluser eht ,hparg a morf devomer si noitcirtser atad ehT .hpargit

.hparg a ton si hcihw hpargitlum a si 3.6 erugif fo tcejbo

( sriap deredronu tcnitsid fo rebmun ehT vi,vj htiw ) vi vj htiw hparg a ni n si secitrev n(n - si sihT .2/)1 yna ni segde fo rebmun mumixam eht n .hparg detceridnu xetrev

nA n yltcaxe htiw hparg detceridnu xetrev n(n - eb ot dias si segde 2/)1 G .etelpmoc 1 etelpmoc eht si elihw secitrev 4 no hparg G2 dna G3 no hparg detcerid a fo esac eht nI .shparg etelpmoc ton era n secitrev

si segde fo rebmun mumixam eht n(n - .)1

( fI v1,v2 ni egde na si ) E(G secitrev eht yas llahs ew neht ,) v1 dna v2 era tnecajda ( egde eht taht dna v1,v2 ) si tnedicni secitrev no v1 dna v2 ni 2 xetrev ot tnecajda secitrev ehT . G2 tnedicni segde ehT .1 dna 5 ,4 era

ni 3 xetrev no G2 )7,3( dna )6,3( ,)3,1( era < fI . v1,v2 xetrev neht ,egde detcerid a si > v1 eb ot dias eb lliwtnecajda ot v2 elihw v2 si morf tnecajda v1 < egde ehT . v1,v2 ot tnedicni si > v1 dna v2 nI . G3 segde eht

.>3,2< dna >1,2< ,>2,1< era 2 xetrev ot tnedicni

hpargitlum a fo elpmaxE 3.6 erugiF .hparg a ton si taht

A hpargbus fo G hparg a si 'G taht hcus V( 'G ) V(G dna ) E( 'G ) E(G fo emos swohs 4.6 erugiF .) fo shpargbus eht G1 dna G3.

A htap xetrev morf vp xetrev ot vq hparg ni G secitrev fo ecneuqes a si vp,vi1,vi2 ,... , v ni ,vq taht hcus(vp,vi1 (,) vi1,vi2 (,... ,) v ni ,vq ni segde era ) E(G fI .) 'G < fo stsisnoc htap eht neht detcerid si vp,vi1 <,> vi,vi2 ,>

<,... v ni ,vq ni segde ,> E( 'G .)

Page 73: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 37

ehT htgnel .ti no segde fo rebmun eht si htap a fo

A htap elpmis eht ylbissop tpecxe secitrev lla hcihw ni htap a si sa hcus htap A .tcnitsid era tsal dna tsrif ni 3 htgnel fo htob era 2,4,2,1 dna 3,4,2,1 shtaP .3,4,2,1 sa etirw ew )3,4( )4,2( )2,1( G1 a si tsrif ehT .

ni htap detcerid elpmis a si 3,2,1 .ton si dnoces eht elihw htap elpmis G3 ni htap a ton si 2,3,2,1 . G3 eht sa ni ton si >2,3< egde E(G3 .)

A elcyc ni elcyc a si 1,3,2,1 .emas eht era secitrev tsal dna tsrif eht hcihw ni htap elpmis a si G1 a si 1,2,1 . ni elcyc G3 elcyc smret eht ot "detcerid" xiferp eht no dda yllamron ew shparg detcerid fo esac eht roF .

a .htap dn

,hparg detceridnu na nI G secitrev owt , v1 dna v2 eb ot dias era detcennoc ni htap a si ereht fi G morf v1 otv2 ecnis( G morf htap a eb osla tsum ereht snaem siht ,detceridnu si v2 ot v1 dias si hparg detceridnu nA .)

secitrev tcnitsid fo riap yreve rof fi detcennoc eb ot vi , vi ni V(G morf htap a si ereht ) vi ot vj ni G .

shparG G1 dna G2 elihw detcennoc era G 4 .ton si 5.6 erugif fo

A tnenopmoc detcennoc eridnu na fo tnenopmoc a ylpmis ro a si hparg detc lamixam .hpargbus detcennocG 4 stnenopmoc owt sah H 1 dna H 2 .)5.6 erugif ees(

A eert hparg detcerid A . hparg )selcyc on sah ,.e.i( cilcyca detcennoc a si G eb ot dias si ylgnortsdetcennoc secitrev tcnitsid fo riap yreve rof fi vi , vj ni V(G morf htap detcerid a si ereht ) vi ot vj osla dna

morf vj ot vi hparg ehT . G3 morf htap on si ereht sa detcennoc ylgnorts ton si v3 ot v2 .

A tnenopmoc detcennoc ylgnorts .detcennoc ylgnorts si taht hpargbus lamixam a si G3 ylgnorts owt sah.stnenopmoc detcennoc

G fo shpargbus eht fo emoS )a( 1

Page 74: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 47

G fo shpargbus eht fo emoS )b( 3

G fo shpargbuS )a( 4.6 erugiF 1 G fo shpargbuS )b( dna 3

.stnenopmoc detcennoc owt htiw hparg A 5.6 erugiF

detcennoc ylgnorts 6.6 erugiF G fo stnenopmoc 3.

ni 1 xetrev fo eerged ehT .xetrev taht ot tnedicni segde fo rebmun eht si xetrev a fo eerged ehT G1 nI .3 si esac G eht enifed ew ,hparg detcerid a si ni - eerged xetrev a fo v hcihw rof segde fo rebmun eht eb ot v si

ehT .daeh eht tuo - rged ee hcihw rof segde fo rebmun eht eb ot denifed si v fo 2 xetreV .liat eht si G3 sahni - tuo ,1 eerged - fI .3 eerged dna 2 eerged di xetrev fo eerged eht si i hparg a ni G htiw n dna secitrev e

taht ees ot ysae si ti neht ,segde e )2/1( = .

1.6 seerT hcraeS yraniB scitsiretcarahC

si dna eertbus tfel sti ni syek eht naht retaerg si edon lanretni na fo yek eht hcihw ni seerT naht rellams .eertbus thgir sti ni syek eht

hcraeS hcraes ( yek,eert )

FI ytpme eert NEHT nruter ton - dnuof FI yek == eulav ni toor NEHT nruter dnuof FI yek > eulav ni toor NEHT hcraes tfel( - ,eertbus )yek hcraes thgir( - ,eertbus )yek

emiT : O )eert fo htped(

noitresnI

6 tresni 01 tresni

Page 75: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 57

noiteleD

.yek eht gnidloh edon fo epyt eht no sdneped edam si noiteled eht yaw ehT

0 eerged fo edoN

edon eht eteleD

1 eerged fo edoN

.rosseccus eht ot rossecederp sti gnitcennoc elihw ,edon eht eteleD

2 eerged fo edoN

tfel eht ni yek tsegral eht gnivah edon eht htiw yek deteled eht gniniatnoc edon eht ecalpeRus thgir eht ni yek tsellams eht gnivah edon eht htiw ro ,eertbus .eertb

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 57

noiteleD

.yek eht gnidloh edon fo epyt eht no sdneped edam si noiteled eht yaw ehT

0 eerged fo edoN

edon eht eteleD

1 eerged fo edoN

.rosseccus eht ot rossecederp sti gnitcennoc elihw ,edon eht eteleD

2 eerged fo edoN

tfel eht ni yek tsegral eht gnivah edon eht htiw yek deteled eht gniniatnoc edon eht ecalpeRus thgir eht ni yek tsellams eht gnivah edon eht htiw ro ,eertbus .eertb

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 57

noiteleD

.yek eht gnidloh edon fo epyt eht no sdneped edam si noiteled eht yaw ehT

0 eerged fo edoN

edon eht eteleD

1 eerged fo edoN

.rosseccus eht ot rossecederp sti gnitcennoc elihw ,edon eht eteleD

2 eerged fo edoN

tfel eht ni yek tsegral eht gnivah edon eht htiw yek deteled eht gniniatnoc edon eht ecalpeRus thgir eht ni yek tsellams eht gnivah edon eht htiw ro ,eertbus .eertb

Page 76: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 67

.2.6 seerT noitceleS A eert noitceles lanretni hcae dna ,syek fo tes a dloh sedon fael eht hcihw ni eert yranib etelpmoc a si

.nerdlihc sti gnoma yek ”renniw“ eht sdloh edon

yeK a gniyfidoM

at tI sek O gol( n .fael a ni yek a fo egnahc a ot esnopser ni eert noitceles a yfidom ot emit )

noitazilaitinI

sekat hctarcs morf eert noitceles a fo noitcurtsnoc ehT O(n level ti gnisrevart yb emit ) - mottob morf esiw .pu

troS lanretxE :noitacilppA

fo tes a neviG n seulav 3 5 51 2 31 41 7 4 1 21 11 6 8 01 9 61 n =61

otni ti edivid M ,skcnuhc 8 01 9 61 1 21 11 6 31 41 7 4 3 5 51 2 M4 =

,knuhc hcae tros yllanretni 61 01 9 8 21 11 6 1 41 31 7 4 51 5 3 2

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 67

.2.6 seerT noitceleS A eert noitceles lanretni hcae dna ,syek fo tes a dloh sedon fael eht hcihw ni eert yranib etelpmoc a si

.nerdlihc sti gnoma yek ”renniw“ eht sdloh edon

yeK a gniyfidoM

at tI sek O gol( n .fael a ni yek a fo egnahc a ot esnopser ni eert noitceles a yfidom ot emit )

noitazilaitinI

sekat hctarcs morf eert noitceles a fo noitcurtsnoc ehT O(n level ti gnisrevart yb emit ) - mottob morf esiw .pu

troS lanretxE :noitacilppA

fo tes a neviG n seulav 3 5 51 2 31 41 7 4 1 21 11 6 8 01 9 61 n =61

otni ti edivid M ,skcnuhc 8 01 9 61 1 21 11 6 31 41 7 4 3 5 51 2 M4 =

,knuhc hcae tros yllanretni 61 01 9 8 21 11 6 1 41 31 7 4 51 5 3 2

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 67

.2.6 seerT noitceleS A eert noitceles lanretni hcae dna ,syek fo tes a dloh sedon fael eht hcihw ni eert yranib etelpmoc a si

.nerdlihc sti gnoma yek ”renniw“ eht sdloh edon

yeK a gniyfidoM

at tI sek O gol( n .fael a ni yek a fo egnahc a ot esnopser ni eert noitceles a yfidom ot emit )

noitazilaitinI

sekat hctarcs morf eert noitceles a fo noitcurtsnoc ehT O(n level ti gnisrevart yb emit ) - mottob morf esiw .pu

troS lanretxE :noitacilppA

fo tes a neviG n seulav 3 5 51 2 31 41 7 4 1 21 11 6 8 01 9 61 n =61

otni ti edivid M ,skcnuhc 8 01 9 61 1 21 11 6 31 41 7 4 3 5 51 2 M4 =

,knuhc hcae tros yllanretni 61 01 9 8 21 11 6 1 41 31 7 4 51 5 3 2

Page 77: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 77

fo eert yranib etelpmoc tcurtsnoc M eht ot dehcatta sknuhc eht htiw sevael

.sevael

htiw eert noitceles a otni eert eht trevnoC eht morf sevael eht ot def gnieb syek eht

sknuhc

eert eht morf renniw eht evomeR

morf eulav txen eht fael ytpme eht ot deeF knuhc gnidnopserroc sti

ni egnahc eht ot eert noitceles eht tsujdA fael eht

lla litnu ssecorp bus noiteled eht taepeR .demusnoc era seulav eht

sekat mhtirogla ehT ,sknuhc eht fo stnemele eht tros yllanretni ot emit O(M ot ) dna ,eert noitceles eht ezilaitini O(n gol M roF .tros noitceles eht mrofrep ot ) M « n emit latot eht

si ytixelpmoc O(n gol n .) .sreffub hguorht og dluohs eert noitceles eht ot sknuhc eht morf stupni ,snoitarepo O/I ecuder oT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 77

fo eert yranib etelpmoc tcurtsnoc M eht ot dehcatta sknuhc eht htiw sevael

.sevael

htiw eert noitceles a otni eert eht trevnoC eht morf sevael eht ot def gnieb syek eht

sknuhc

eert eht morf renniw eht evomeR

morf eulav txen eht fael ytpme eht ot deeF knuhc gnidnopserroc sti

ni egnahc eht ot eert noitceles eht tsujdA fael eht

lla litnu ssecorp bus noiteled eht taepeR .demusnoc era seulav eht

sekat mhtirogla ehT ,sknuhc eht fo stnemele eht tros yllanretni ot emit O(M ot ) dna ,eert noitceles eht ezilaitini O(n gol M roF .tros noitceles eht mrofrep ot ) M « n emit latot eht

si ytixelpmoc O(n gol n .) .sreffub hguorht og dluohs eert noitceles eht ot sknuhc eht morf stupni ,snoitarepo O/I ecuder oT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 77

fo eert yranib etelpmoc tcurtsnoc M eht ot dehcatta sknuhc eht htiw sevael

.sevael

htiw eert noitceles a otni eert eht trevnoC eht morf sevael eht ot def gnieb syek eht

sknuhc

eert eht morf renniw eht evomeR

morf eulav txen eht fael ytpme eht ot deeF knuhc gnidnopserroc sti

ni egnahc eht ot eert noitceles eht tsujdA fael eht

lla litnu ssecorp bus noiteled eht taepeR .demusnoc era seulav eht

sekat mhtirogla ehT ,sknuhc eht fo stnemele eht tros yllanretni ot emit O(M ot ) dna ,eert noitceles eht ezilaitini O(n gol M roF .tros noitceles eht mrofrep ot ) M « n emit latot eht

si ytixelpmoc O(n gol n .) .sreffub hguorht og dluohs eert noitceles eht ot sknuhc eht morf stupni ,snoitarepo O/I ecuder oT

Page 78: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 87

stseroF 3.6 etaerc era spihsnoitaler tsurt niamodretni tluafed ehT .noitaerc rellortnoc niamod gnirud metsys eht yb d

tcennoc ot deriuqer era taht spihsnoitaler tsurt fo rebmun ehT n si sniamod n – era sniamod eht rehtehw ,1tnerap suougitnoc ,elgnis a ni deknil - suougitnoc etarapes erom ro owt etutitsnoc yeht ro yhcrareih dlihc

tnerap - .seihcrareih dlihc

a etaerc ,secapseman tnereffid evah ot noitazinagro emas eht ni sniamod rof yrassecen si ti nehW etarapesswodniW nI .ecapseman hcae rof eert owt yb yllacitamotua deknil era seert fo stoor eht ,0002 - ,yaw

detaler si taht eert elgnis A tserof a mrof spihsnoitaler tsurt yb deknil seerT .spihsnoitaler tsurt evitisnarterof a setutitsnoc seert rehto on ot .eert eno fo ts

swodniW eritne eht rof serutcurts eert ehT fo mrof eht ni yrotceriD evitcA ni derots era tserof 0002tnerap - eert dna dlihc - ssalc( stcejbo tnuocca tsurt sa derots era spihsnoitaler esehT .spihsnoitaler toor

niamoDdetsurt tnoc metsyS eht ni ) ni niamod hcae roF .noititrap yrotcerid niamod cificeps a nihtiw renia eert rehtona ot ,toor eert a fo esac eht ni ,ro( niamod tnerap a ot noitcennoc sti tuoba noitamrofni ,tserof a

reve ot detacilper si taht atad noitarugifnoc eht ot dedda si )niamod toor ,eroferehT .tserof eht ni niamod y gnidulcni ,tserof eritne eht rof erutcurts eert eht fo egdelwonk sah tserof eht ni rellortnoc niamod yreve eerT niamoD yrotceriD evitcA ni erutcurts eert eht weiv nac uoY .seert neewteb sknil eht fo egdelwonk

.reganaM

4.6 steS tniojsiD fo noitatneserpeR teS

a ,ecneics retupmoc nI tes ralucitrap yna tuohtiw ,seulav niatrec erots nac taht erutcurts atad tcartsba na sidna ,redro .tes etinif a fo tpecnoc lacitamehtam eht fo noitatnemelpmi retupmoc a si tI .seulav detaeper on

rof dengised era serutcurts atad tes emoS stes citats yreuq ylno wolla dna ,emit htiw egnahc ton od tahtsnoitarepo — emos ni seulav eht gnitaremune ro ,tes eht ni si eulav nevig a rehtehw gnikcehc sa hcus

rehtO .redro yrartibra dellac ,stnairav cimanyd ro stes elbatum noiteled ro/dna noitresni eht osla wolla ,.tes eht morf stnemele fo

eht fo redro eht gnirongi ,tsil a esu nac eno ,elpmaxe roF .syaw ynam ni detnemelpmi eb nac tes Adna stnemele etnemelpmi netfo era steS .seulav detaeper diova ot erac gnikat fo srovalf suoirav gnisu d

dna ,selbat hsah ,seirt ,seert .erom yek hcae fo eulav eht hcihw ni ,yarra evitaicossa )laitrap( a sa ,detnemelpmi dna ,nees eb nac tes A - eulav

eht sah riap .epyt tinu idni rieht htiw deifitnedi yllareneg era stes ,yroeht epyt nI :noitcnuf rotacyam epyt fo seulav fo tes a ,ylgnidrocca yb deledom eb yam stesbus dna sepytbuS( . ro yb detoned ebeb yam stes tneitouq dna ,sepyt tnemenifer ).sdiotes yb decalper

snoitarepO rutcurts tes citats a yb dedivorp eb yam taht snoitarepo lacipyT e S era

(fo_tnemele • x,S eulav eht rehtehw skcehc :) x tes eht ni si S. (ytpme • S tes eht rehtehw skcehc :) S .ytpme si

(ezis • S ni stnemele fo rebmun eht snruter :) S. (etaremune • S fo stnemele eht sdleiy :) S .redro yrartibra emos ni

(kcip • S fo tnemele yrartibra na snruter :) S. (dliub • x ,1 x ,2 …, nx seulav htiw erutcurts tes a setaerc :), x ,1 x ,2 …, nx .

taht tcejbo erudecorp a ,rotareti na ro ,stnemele eht lla fo tsil a nruter yam noitarepo etaremune ehTerom eno snruter fo eulav S .llac hcae ta

nyD :dda yllacipyt serutcurts tes cima (etaerc • n ot pu gnidloh fo elbapac tub ytpme yllaitini ,erutcurts tes wen a setaerc :) n .stnemele

Page 79: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 97

(dda • S,x tnemele eht sdda :) x ot S .ydaerla ereht ton si ti fi , (eteled • S,x tnemele eht sevomer :) x morf S eht si ti fi , .er

(yticapac • S taht seulav fo rebmun mumixam eht snruter :) S .dloh nac no dneped lliw noitarepo hcae fo tsoc ehT .snoitarepo eseht fo emos ylno wolla yam serutcurts tes emoS

eht tes eht ni derots seulav ralucitrap eht no osla ylbissop dna ,noitatnemelpmi hcihw ni redro eht dna ,.detresni era yeht ,evoba eht fo smret ni denifed eb )elpicnirp ni( nac taht snoitarepo rehto ynam era erehT

:sa hcus (pop • S fo tnemele yrartibra na snruter :) S morf ti gniteled , S. (dnif • S , P fo tnemele na snruter :) S sitas taht etaciderp nevig a seif P. (raelc • S fo stnemele lla eteled :) S.

:yroeht tes fo snoitarepo naelooB eht enifed yam eno ,ralucitrap nI (noinu • S,T stes fo noinu eht snruter :) S dna T.

(noitcesretni • S,T stes fo noitcesretni eht snruter :) S dna T. • (ecnereffid S,T stes fo ecnereffid eht snruter :) S dna T.

(tesbus • S,T tes eht rehtehw stset taht etaciderp a :) S tes fo tesbus a si T. :epyt laiceps a fo stnemele htiw stes rof denifed eb nac snoitarepo rehtO

(mus • S fo stnemele lla fo mus eht snruter :) S .)"mus" fo noitinifed emos rof( (tseraen • S,x fo tnemele eht snruter :) S ot eulav ni tsesolc si taht x .)noiretirc emos yb(

snoitarepo lanoitidda htiw serutcurts tes sa deweiv eb nac serutcurts atad tcartsba rehto ynam ,yroeht nIro/dna i smoixa lanoitidda eb nac paeh tcartsba na ,elpmaxe roF .snoitarepo dradnats eht no desopm

erutcurts tes a sa deweiv (nim a htiw S .eulav tsellams fo tnemele eht snruter taht noitarepo ) snoitatnemelpmI

effid edivorp hcihw ,serutcurts atad suoirav gnisu detnemelpmi eb nac steS edart ecaps dna emit tner - sffosuoirav rof dezilaiceps yrev fo ycneiciffe eht evorpmi ot dengised era snoitatnemelpmi emoS .snoitarepo

sa hcus ,snoitarepo ot evirts yllacipyt "esu lareneg" sa debircsed snoitatnemelpmI .noinu ro tseraentnemele eht ezimitpo dna ,dda ,fo_ .noitarepo eteled

fles a ,yleman ,syarra evitaicossa sa yaw emas eht ni detnemelpmi ylnommoc era steS - yranib gnicnalab

eert hcraes stes detrosnu rof elbat hsah a ro ,)snoitarepo tsom rof )n gol(O sah hcihw( stes detros rof)1(O sah hcihw( va egare - tsrow )n(O tub ,esac - ]1[elbat hsah raenil detros A .)snoitarepo tsom rof ,esac

edivorp ot desu eb yam .stes deredro yllacitsinimreted

..1 sregetni eht fo tesbus a ralucitrap nI .syarra edulcni sdohtem ralupop rehtO n detnemelpmi eb nacsa yltneiciffe na n- A .snoitarepo noitcesretni dna noinu tneiciffe yrev troppus osla hcihw ,yarra tib tib

tes a stnemelpmi pam moolB llams a gniksir tub noitatneserper tcapmoc yrev a gnisu ,yllacitsilibaborp.seireuq no sevitisop eslaf fo ecnahc tes naelooB ehT erom fo smret ni detnemelpmi eb nac snoitarepo

tub ,)dda dna ,raelc ,pop( snoitarepo yratnemele emit citotpmysa rewol dleiy yam smhtirogla dezilaiceps,elpmaxe rof ,stsil detros sa detnemelpmi era stes fI .sdnuob (noinu rof mhtirogla evian eht S,T kat lliw ) e

htgnel eht ot lanoitroporp edoc m fo S htgnel eht semit n fo T a saerehw ; gnigrem tsil eht fo tnairav ot lanoitroporp emit ni boj eht od lliw mhtirogla m+n tes dezilaiceps era ereht ,revoeroM . serutcurts atad

noinu eht sa hcus( - taht )erutcurts atad dnif eht ta ,snoitarepo eseht fo erom ro eno rof dezimitpo era .srehto fo esnepxe

seerT yraniB gnitnuoC 5.6 : :noitinifeD A eert yranib sti dellac xetrev laiceps a sah toor eert eht fo tser eht ,pot eht ta xetrev siht morF .

vah yam xetrev hcaE.drawnwod nward si a e dlihc tfel a ro/dna dlihc thgir . .elpmaxE :si secitrev 3 ,2 ,1 htiw seert yranib fo rebmun ehT .elpmaxE :si secitrev 4 htiw seert yranib fo rebmun ehT

Page 80: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 08

:erutcejnoC . si secitrev n no seert yranib fo rebmun ehT :foorP :rehtie eert yranib yrevE

! v on saH )0x( secitre – ro – ! )x( xetrev toor eno sa nwod skaerB

.)2)x(B( htaeneb seert yranib owt htiw gnola 1 = nb edulcnoc eW .2)x(Bx + 1 = )x(B seifsitas seert yranib rof noitcnuf gnitareneg eht ,eroferehT

. $ n n2#1+n :yaw rehtonA .nb rof ecnerrucer a dniF :etoN

.0b3b + 1b2b + 2b1b + 3b0b = 4b n%= nb ,lareneg nI . i−1−nbib 0=i 1−

n&' 1"n & + 1 slauqe )x(B ,eroferehT 0=i 1−n&' 1"n & x + 1 = nx ( I−1−nbib 0=i 1− nbib .2)x(Bx+1 = ( kxkb 0"k &'( kxkb 0"k &' x+1 = kx ( I−kbib 0=i k&' 0"k & x+1 = 1−nx ( I−1−

6.6 epyT ataD tcartsbA hparG ehT : nI ecneics retupmoc a , hparg na si epyt atad tcartsba aht eht tnemelpmi ot tnaem si t hparg dna

hpargrepyh morf stpecnoc scitamehtam )elbatum ylbissop dna( etinif a fo stsisnoc erutcurts atad hparg A.tes dellac ,sriap deredro fo segde ro scra fo , dellac seititne niatrec sedon ro secitrev ,scitamehtam ni sA .

( egde na x,y ot dias si ) tniop ro og morf x ot y eb yam ro ,erutcurts hparg eht fo trap eb yam sedon ehT . ro secidni regetni yb detneserper seititne lanretxe secnerefer .

emos egde hcae ot etaicossa osla yam erutcurts atad hparg A eulav egde a ro lebal cilobmys a sa hcus ,nel ,yticapac ,tsoc( etubirtta ciremun .).cte ,htg

smhtiroglA

rehgih lacipyT .ecneics retupmoc nihtiw tseretni fo dleif tnacifingis a era smhtirogla hparG - level ekil ,sedon owt neewteb htap a gnidnif :era shparg htiw detaicossa snoitarepo htped - hcraes tsrif dna

htdaerb - hcraes tsrif ekil ,rehtona ot edon eno morf htap tsetrohs eht gnidnif dna mhtirogla s'artskjiD A . eht fo mrof eht ni stsixe osla edon rehto yreve ot edon hcae morf htap tsetrohs eht gnidnif ot noitulos

dyolF – mhtirogla llahsraW A. hparg detcerid a sa nees eb nac wolf krowten a sah egde hcae erehw , ehT .wolf a seviecer egde hcae dna yticapac droF – mhtirogla nosrekluF tuo dnif ot desu si mumixam eht

wolf hparg a ni knis a ot ecruos a morf

snoitarepO

erutcurts atad hparg a yb dedivorp snoitarepo cisab ehT G :edulcni yllausu

(tnecajda G , x , y don morf egde na si ereht rehtehw stset :) e x edon ot y . (srobhgien G , x sedon lla stsil :) y morf egde na si ereht taht hcus x ot y . (dda G , x , y ot sdda :) G morf egde eht x ot y .ereht ton si ti fi , (eteled G , x , y morf egde eht sevomer :) x ot y .ereht si ti fi , (eulav_edon_teg G , x edon eht htiw detaicossa eulav eht snruter :) x . (eulav_edon_tes G , x , a edon eht htiw detaicossa eulav eht stes :) x ot a .

:edivorp osla yllausu segde eht ot seulav etaicossa taht serutcurtS

(eulav_egde_teg G , x , y eht ot detaicossa eulav eht snruter :) ( egde x,y .) (eulav_egde_tes G , x , y , v ( egde eht ot detaicossa eulav eht stes :) x,y ot ) v .

Page 81: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 18

snoitatneserpeR

:ecitcarp ni desu era shparg fo noitatneserper eht rof serutcurts atad tnereffiD

tsil ycnecajdA – a serots xetrev yreve dna ,stcejbo ro sdrocer sa derots era secitreV tsil fo .secitrev eht no atad lanoitidda fo egarots eht swolla erutcurts atad sihT .secitrev tnecajda

tsil ecnedicnI – trev hcaE .stcejbo ro sdrocer sa derots era segde dna secitreV sti serots xe fo egarots eht swolla erutcurts atad sihT .secitrev tnedicni sti serots egde hcae dna ,segde tnedicni

.segde dna secitrev no atad lanoitidda xirtam ycnecajdA – owt A - dna secitrev ecruos tneserper swor eht hcihw ni ,xirtam lanoisnemid

.yllanretxe derots eb tsum secitrev dna segde no ataD .secitrev noitanitsed tneserper snmuloc .secitrev fo riap hcae neewteb derots eb nac egde eno rof tsoc eht ylnO

xirtam ecnedicnI – owt A - secitrev eht tneserper swor eht hcihw ni ,xirtam naelooB lanoisnemid tnedicni si wor a ta xetrev eht rehtehw etacidni seirtne ehT .segde eht tneserper snmuloc dna ot

.nmuloc a ta egde eht

.7.6 SNOITSEUQ DEDNEMMOCER .slasrevart tserof eht nialpxE .tserof enifeD .1

.eert hcraes yraniB enifeD .2 ?elpmaxe htiw nialpxE

eert a ni sedon lanimret ,eert a ni htap a enifeD .3

nib a ni edon a gnihcraes taht dias si ti yhW .4 ?eert yranib elpmis a fo taht naht tneiciffe si eert hcraes yra

.TDA tes fo snoitacilppa eht tsiL .5

TDA tes tniojsid yb naem uoy od tahW .6

.tes eht ni snoitarepo tcartsba eht tsiL .7

?hparg detceridnu & hparg detcerid a si tahW .hparG enifeD .8

tahW .9 ?hparg a ni htap enifeD ?hparg dethgiew a si

?hparg a fo eergedni & hparg a fo eergedtuo enifeD .01

Page 82: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 28

TINU – 7 : SEUEUQ YTIROIRP ytiroirP ueuQ e:

Ne de rof ytiroirp :eueuq nI a lum ti user en iv or nemn t, eht nitarepo g sys t me s ehc d lu re sum t d edice ihw ch fo

se rev al pr sesseco to run o ln y f ro a f dexi ep r oi d f ro t mi e. For t ah t we can esu ht e gla o ir t mh of Q UEU E, where oJ bs era yllaitini p decal at t eh

ne d of eht ueuq e. ehT reludehcs lliw er p etae d yl ekat eht tsrif job no eht ,eueuq nur it nu t li ie t reh ti

sinif h se or its it me il mit si up, and alp c gni it at t eh and of t eh q ueu e if it do se n t’ if nish.

sihT ygetarts si g rene a yll ton pa p amixor t ,e esuaceb yrev rohs t jo sb lliw noos to t eka a nol g emit esuaceb of eht wa ti invo devl to .nur

reneG a ll y, ti si mi port tna t ah t trohs j bo s hsinif sa tsaf sa ,elbissop so eseht sboj dluohs evah erp ec dence o ev r jo sb that have a rl eady eb en runni gn .

rehtruF om r ,e so em jo sb taht era on t rohs t era llits ev ry pmi ort na t na d hs o lu d sla o evah rp ecnedece .

sihT part ci ular pa p cil ation s smee to riuqer e a spec lai ik nd of qu ue e, k on wn as a PRI RO YTI Q EU EU .

uQ ytiroirP e :eu tI si a noitcelloc of or ed r de e nemel ts aht t p ivor des tsaf ssecca ot t eh m mini um or mumixam e el m ne t.

isaB c arepO t snoi demrofrep yb rp ytiroi euq ue :era 1. arepo tresnI it no 2. De el et min ope tar ion

resnI t po are t noi is t eh eq viu a nel t of euq u ’e s eueuqnE repo a .noit De el temin opera it no si the irp ority q eueu laviuqe ent of eht s’eueuq ueuqeD e tarepo i no .

In es (tr H) irP o tir y euQ ue H

tatnemelpmI ion: erehT ra e eerht ways for nemelpmi t ni g irp o ytir .eueuq ehT y :era

1. iL n dek sil t 2. aniB yr aeS r hc t eer 3. aniB yr paeH

elgniS .1.7 - elbuoD dna - seueuQ ytiroirP dednE :

elgnis( A - tes deredro na no snoitarepo gniwollof eht gnitroppus epyt atad a si eueuq ytiroirp )dedne fo :seulav

;)xaMdniF( eulav mumixam eht dnif )1 ;)xaMeteleD( eulav mumixam eht eteled )2

.))x(tresnI( x eulav wen a dda )3 dna niMdniF htiw )2 dna )1 snoitarepo gnitutitsbus yb denifeder eb nac eueuq ytiroirp eht ,ylsuoivbO

areveS .ylevitcepser ,niMeteleD erom gnisu emos dna yarra na ni derots ylticilpmi emos ,serutcurts lxam gnidulcni ,epyt atad siht gnitnemelpmi rof detneserp neeb evah ,serutcurts atad xelpmoc - ro( spaeh

nim - )spaeh

eD lt me ni (H)

Page 83: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 38

xam a ,yllautpecnoC - eitreporp gniwollof eht gnivah eert yranib a si paeh :s paeh )a - eht ypucco level tsal eht no sevael eht dna ,slevel tnecajda owt tsom ta no eil sevael lla :epahs

.etelpmoc era slevel rehto lla ;snoitisop tsomtfel xam )b - ti ta derots seulav eht ot lauqe ro naht retaerg si edon a ta derots eulav eht :gniredro A .nerdlihc s

xam - n na ni derots eb nac dna emit raenil ni detcurtsnoc eb nac n ezis fo paeh - si ti ecneh ;yarra tnemele.]g[ erutcurts atad ticilpmi na sa ot derrefer

xam a nehW - ,emit tnatsnoc ni demrofrep eb nac xaMdniF ,eueuq ytiroirp a stnemelpmi paeh htob elihw

elbuod eht ,epyt atad lufrewop erom a redisnoc llahs eW .emit cimhtiragol evah )x(tresnI dna xaMeteleD - dna ,xaMeteleD ,niMeteleD sa llew sa ,xaMdniF dna niMdniF htob swolla hcihw ,eueuq ytiroirp dedne

itacilppa tnatropmi nA .snoitarepo )x(tresnI . troskciuq lanretxe ni si epyt atad siht fo no ,elpmaxe rof ;snoitarepo evoba eht lla fo noitatnemelpmi tneiciffe wolla ton seod paeh lanoitidart A

xam a ni emit )tnatsnoc fo daetsni( raenil seriuqer niMdniF - siht gnimocrevo ot hcaorppa enO .paehcisnirtni xam a ecalp ot si ,spaeh fo noitatimil - kcab“ paeh - ot - nim a htiw ”kcab - .paeh

noitinifeD

A elbuod - )QPED( eueuq ytiroirp dedne a sah tnemele hcaE .stnemele erom ro orez fo noitcelloc a sielbuod a no demrofrep snoitarepo ehT .eulav ro ytiroirp - tiroirp dedne :era eueuq y

.1 ytpme si QPED eht ffi eurt nruter ... )(ytpmEsi

.2 QPED eht ni stnemele fo rebmun eht nruter ... )(ezis

.3 ytiroirp muminim htiw tnemele nruter ... )(niMteg

.4 ytiroirp mumixam htiw tnemele nruter ... )(xaMteg

.5 QPED eht otni x tnemele eht tresni ... )x(tup

.6 tnemele siht nruter dna ytiroirp muminim htiw tnemele na evomer ... )(niMevomer

.7 tnemele siht nruter dna ytiroirp mumixam htiw tnemele na evomer ... )(xaMevomer

gnitroS lanretxE ot noitacilppA

s lanretni ehT ehT .)3.2.91 noitceS ees( tros kciuq si emit nur detcepxe tseb eht sah taht dohtem gnitro elddim ehT .R dna ,M ,L spuorg eerht otni detros eb ot stnemele eht noititrap ot si tros kciuq ni aedi cisab

eht dellac tnemele elgnis a sniatnoc M puorg tovip e lla , dna ,tovip eht =< era L puorg tfel eht ni stnemel tnemele thgir dna tfel eht ,gninoititrap siht gniwolloF .tovip eht => era R puorg thgir eht ni stnemele lla .ylevisrucer detros era spuorg

ht ni dleh eb nac naht stnemele erom evah ew ,tros lanretxe na nI ehT .retupmoc ruo fo yromem e

eht nehW .ksid eht no tfel eb ot si ecneuqes detros eht dna ksid a no yllaitini era detros eb ot stnemele si M puorg elddim eht ,tros kciuq lanretxe na ot dednetxe si evoba deniltuo dohtem tros kciuq lanretni

sa egral sa edam :si ygetarts tros kciuq lanretxe ehT .QPED a fo esu eht hguorht elbissop

.1 lliw QPED eht ni stnemele ehT .QPED lanretni na otni tif lliw sa stnemele ynam sa ni daeR .stnemele fo puorg elddim eht eb yllautneve

.2 ele txen eht fI .stnemele gniniamer eht ni daeR ,QPED eht ni tnemele tsellams eht =< si tnem ni tnemele tsegral eht => si tnemele txen eht fI .puorg tfel eht fo trap sa tnemele txen siht tuptuo xam eht rehtie evomer ,esiwrehtO .puorg thgir eht fo trap sa tnemele txen siht tuptuo ,QPED eht

tnemele nim ro xam eht fi ;)yletanretla ro ylmodnar edam eb yam eciohc eht( QPED eht morf sa tnemele devomer eht tuptuo ,esiwrehto ;puorg thgir eht fo trap sa ti tuptuo ,devomer si tnemele

.QPED eht otni tnemele tupni ylwen eht tresni ;puorg tfel eht fo trap .3 eht tuptuO .puorg elddim eht sa ,redro detros ni ,QPED eht ni stnemele .4 .ylevisrucer spuorg thgir dna tfel eht troS

Page 84: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 48

:sQPED rof sdohteM cireneG elgnis morf serutcurts atad QPED tneiciffe ta evirra ot tsixe sdohtem lareneG - )QP( eueuq ytiroirp dedne

ht serutcurts atad siht( noitarepo )edoNeht(evomer eht fo noitatnemelpmi tneiciffe na edivorp osla ta ,sdohtem eseht fo tselpmis ehT .)QP eht morf edoNeht edon eht sevomer noitarepo erutcurts laud

dohtem rehtegot stnemele QPED eht lla fo QP xam a dna QP nim a htob sniatniam , htiwsretniop ecnednopserroc emas eht niatnoc taht QP xam eht dna QP nim eht fo sedon eht neewteb

era sretniop ecnednopserroC .4 ,5 ,2 ,7 ,6 stnemele eht rof erutcurts paeh laud a swohs 1 erugiF .tnemele .sworra der sa nwohs

paeh lauD 1 erugiF

erots ot yrassecen si ti ,paeh xam eht dna nim eht htob ni derots tnemele hcae swohs erugif eht hguohtlA .spaeh owt eht fo eno ylno ni tnemele hcae

rebmun eht fo kcart speek taht ezis elbairav a gnisu yb detnemelpmi era snoitarepo ezis dna ytpmEsi ehT

fo tnemele mumixam eht dna paeh nim eht fo toor eht ta si tnemele muminim ehT .QPED eht ni stnemele dna spaeh xam eht dna nim eht htob otni x tresni ew ,x tnemele na tresni oT .paeh xam eht fo toor eht ta si

ol eht neewteb sretniop ecnednopserroc pu tes neht eht evomer oT .spaeh xam dna nim eht ni x fo snoitac eht si edoNeht erehw ,)edoNeht(evomer a dna paeh nim eht morf niMevomer a od ew ,tnemele muminim ni devomer si tnemele mumixam ehT .paeh xam eht morf ,tnemele devomer eht rof edon gnidnopserroc

golana na .yaw suo

ecnednopserroc fael dna latoT flah ,eseht fo htob nI .sdohtem ecnednopserroc detacitsihpos erom era ,ddo si stnemele fo rebmun eht nehW .QP xam eht ni flah rehto eht dna QP nim eht ni era stnemele eht

ub sihT .reffub a ni deniater si tnemele eno ,ecnednopserroc latot nI .QP rehtie ni ton si tnemele dereff gnidnopserroc a si )b,a( .QP xam eht fo b tnemele tcnitsid a htiw deriap si QP nim eht ni a tnemele hcae

nednopserroc latot a swohs 2 erugiF .)b(ytiroirp =< )a(ytiroirp taht hcus stnemele fo riap eht rof paeh ec nwohs era sriap gnidnopserroC .reffub eht ni si 9 tnemele ehT .01 ,9 ,8 ,7 ,6 ,5 ,5 ,4 ,4 ,3 ,2 stnemele 11

.sworra der yb

paeh ecnednopserroc latoT 2 erugiF

ot deriuqer si QP xam dna nim eht fo tnemele fael hcae ,ecnednopserroc fael nI gnidnopserroc a fo trap eb .paeh ecnednopserroc fael a swohs 3 erugiF .riap gnidnopserroc yna ni eb ton deen stnemele faelnoN .riap

Page 85: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 58

paeh ecnednopserroc fael A 3 erugiF

QPED eht ,revewoH .serutcurts laud od naht ecaps ssel eriuqer serutcurts ecnednopserroc fael dna latoT .serutcurts laud rof esoht naht xelpmoc erom era serutcurts ecnednopserroc fael dna latot rof smhtirogla

opserroc fael ,sepyt ecnednopserroc eerht eht fO QPED tsetsaf eht ni stluser yllareneg ecnedn .serutcurts ecnednopserroc

thgieh ,spaeh morf serutcurts QPED ta evirra nac ew ,sdohtem ecnednopserroc debircsed eht fo yna gnisU

dna ,seert tsitfel desaib spaeh gniriap dna ,)(niMevomer ,)x(tup snoitarepo eht ,serutcurts PQED eseht nI .a si siht ,spaeh gniriap rof ,QPED eht ni stnemele fo rebmun eht si n( emit )n gol(O ekat )(xaMevomer n

ytixelpmoc dezitroma .emit )1(O ekat snoitarepo QPED gniniamer eht dna ,)

.2.7 tsitfeL :eert snoitinifeD nA: edon lanretxe .dlihc gnissim a fo noitacol a ni edon yranigami na si

noitatoN eht teL . s- eulav .edon lanretxe na ot edon eht morf ecnatsid tsetrohs eht eb edon a fo

s eht sah edon lanretxe nA - .0 fo eulav s eht sah edon lanretni nA - s eht fo muminim eht sulp 1 fo eulav - lanretxe dna lanretni sti fo seulav

.nerdlihc

thgieH - seerT tsitfeL desaiB

a nI thgieh - el desaib eert tsitf s eht - s eht naht rellams ton si edon a fo dlihc tfel a fo eulav - eht fo eulav .edon eht fo dlihc thgir

thgieh - desaib thgieh non - desaib

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 58

paeh ecnednopserroc fael A 3 erugiF

QPED eht ,revewoH .serutcurts laud od naht ecaps ssel eriuqer serutcurts ecnednopserroc fael dna latoT .serutcurts laud rof esoht naht xelpmoc erom era serutcurts ecnednopserroc fael dna latot rof smhtirogla

opserroc fael ,sepyt ecnednopserroc eerht eht fO QPED tsetsaf eht ni stluser yllareneg ecnedn .serutcurts ecnednopserroc

thgieh ,spaeh morf serutcurts QPED ta evirra nac ew ,sdohtem ecnednopserroc debircsed eht fo yna gnisU

dna ,seert tsitfel desaib spaeh gniriap dna ,)(niMevomer ,)x(tup snoitarepo eht ,serutcurts PQED eseht nI .a si siht ,spaeh gniriap rof ,QPED eht ni stnemele fo rebmun eht si n( emit )n gol(O ekat )(xaMevomer n

ytixelpmoc dezitroma .emit )1(O ekat snoitarepo QPED gniniamer eht dna ,)

.2.7 tsitfeL :eert snoitinifeD nA: edon lanretxe .dlihc gnissim a fo noitacol a ni edon yranigami na si

noitatoN eht teL . s- eulav .edon lanretxe na ot edon eht morf ecnatsid tsetrohs eht eb edon a fo

s eht sah edon lanretxe nA - .0 fo eulav s eht sah edon lanretni nA - s eht fo muminim eht sulp 1 fo eulav - lanretxe dna lanretni sti fo seulav

.nerdlihc

thgieH - seerT tsitfeL desaiB

a nI thgieh - el desaib eert tsitf s eht - s eht naht rellams ton si edon a fo dlihc tfel a fo eulav - eht fo eulav .edon eht fo dlihc thgir

thgieh - desaib thgieh non - desaib

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 58

paeh ecnednopserroc fael A 3 erugiF

QPED eht ,revewoH .serutcurts laud od naht ecaps ssel eriuqer serutcurts ecnednopserroc fael dna latoT .serutcurts laud rof esoht naht xelpmoc erom era serutcurts ecnednopserroc fael dna latot rof smhtirogla

opserroc fael ,sepyt ecnednopserroc eerht eht fO QPED tsetsaf eht ni stluser yllareneg ecnedn .serutcurts ecnednopserroc

thgieh ,spaeh morf serutcurts QPED ta evirra nac ew ,sdohtem ecnednopserroc debircsed eht fo yna gnisU

dna ,seert tsitfel desaib spaeh gniriap dna ,)(niMevomer ,)x(tup snoitarepo eht ,serutcurts PQED eseht nI .a si siht ,spaeh gniriap rof ,QPED eht ni stnemele fo rebmun eht si n( emit )n gol(O ekat )(xaMevomer n

ytixelpmoc dezitroma .emit )1(O ekat snoitarepo QPED gniniamer eht dna ,)

.2.7 tsitfeL :eert snoitinifeD nA: edon lanretxe .dlihc gnissim a fo noitacol a ni edon yranigami na si

noitatoN eht teL . s- eulav .edon lanretxe na ot edon eht morf ecnatsid tsetrohs eht eb edon a fo

s eht sah edon lanretxe nA - .0 fo eulav s eht sah edon lanretni nA - s eht fo muminim eht sulp 1 fo eulav - lanretxe dna lanretni sti fo seulav

.nerdlihc

thgieH - seerT tsitfeL desaiB

a nI thgieh - el desaib eert tsitf s eht - s eht naht rellams ton si edon a fo dlihc tfel a fo eulav - eht fo eulav .edon eht fo dlihc thgir

thgieh - desaib thgieh non - desaib

Page 86: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 68

gnigreM thgieH - seerT tsitfeL desaiB

mhtirogla evisruceR

thgieh ytpmenon owt redisnoC - no )naht rellams ,.g.e( noitaler a dna ,B dna A seert tsitfel desaib .syek eht fo seulav eht

yek eht emussA - yek eht naht reggib ton si A fo eulav - B fo eulav A fo toor eht sa eertbus tfel emas eht evah eert degrem eht fo toor eht teL thgir eht htiw B gnigrem yb deniatbo eertbus thgir eht evah eert degrem eht fo toor eht teL

.A fo eertbus s eht eert degrem eht ni fI - ht naht rellams si eertbus tfel eht fo eulav s e - ,eertbus thgir eht fo eulav

.seertbus eht egnahcretni

yek eht emussa ,elpmaxe gniwollof eht roF - s sti slauqe edon hcae fo eulav - .eulav

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 68

gnigreM thgieH - seerT tsitfeL desaiB

mhtirogla evisruceR

thgieh ytpmenon owt redisnoC - no )naht rellams ,.g.e( noitaler a dna ,B dna A seert tsitfel desaib .syek eht fo seulav eht

yek eht emussA - yek eht naht reggib ton si A fo eulav - B fo eulav A fo toor eht sa eertbus tfel emas eht evah eert degrem eht fo toor eht teL thgir eht htiw B gnigrem yb deniatbo eertbus thgir eht evah eert degrem eht fo toor eht teL

.A fo eertbus s eht eert degrem eht ni fI - ht naht rellams si eertbus tfel eht fo eulav s e - ,eertbus thgir eht fo eulav

.seertbus eht egnahcretni

yek eht emussa ,elpmaxe gniwollof eht roF - s sti slauqe edon hcae fo eulav - .eulav

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 68

gnigreM thgieH - seerT tsitfeL desaiB

mhtirogla evisruceR

thgieh ytpmenon owt redisnoC - no )naht rellams ,.g.e( noitaler a dna ,B dna A seert tsitfel desaib .syek eht fo seulav eht

yek eht emussA - yek eht naht reggib ton si A fo eulav - B fo eulav A fo toor eht sa eertbus tfel emas eht evah eert degrem eht fo toor eht teL thgir eht htiw B gnigrem yb deniatbo eertbus thgir eht evah eert degrem eht fo toor eht teL

.A fo eertbus s eht eert degrem eht ni fI - ht naht rellams si eertbus tfel eht fo eulav s e - ,eertbus thgir eht fo eulav

.seertbus eht egnahcretni

yek eht emussa ,elpmaxe gniwollof eht roF - s sti slauqe edon hcae fo eulav - .eulav

Page 87: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 78

moc emiT ytixelp

.eert emoctuo eht fo htap tsomthgir eht ni raeniL htap tsetrohs a si eert emoctuo eht eht fo htap tsomthgir ehT gol naht erom niatnoc t’nac htap tsetrohs A n .sedon

foorP gol naht erom niatnoc nac htap tsetrohs eht fI n tsrif eht neht ,sedon gol + 1 n dluohs slevel2 edulcni 0 2 + 1 + 2 + gol n 2 = gol+1 n - 2 = 1 n - rof ,esac a hcus nI .sedon 1 > n htiw pu dne ew 1 n

> 2 n - .1

spaeH laimoniB .3.7 :

paeh laimoniB a si paeh a ot ralimis paeh yranib si sihT .spaeh owt gnigrem ylkciuq stroppus osla tub eht fo noitatnemelpmi na sa tnatropmi si tI .erutcurts eert laiceps a gnisu yb deveihca paeh elbaegrem

atad tcartsba epyt a si hcihw ,)paeh elbadlem dellac osla( eueuq ytiroirp A .noitarepo egrem gnitroppus fo noitcelloc a sa detnemelpmi si paeh laimonib laimonib seert a htiw erapmoc( paeh yranib a sah hcihw ,

is a fo epahs elgn eert yranib A .) eert laimonib :ylevisrucer denifed si

edon elgnis a si 0 redro fo eert laimonib A redro fo eert laimonib A k t laimonib fo stoor era nerdlihc esohw edon toor a sah sredro fo seer

k ,1− k .)redro siht ni( 0 ,1 ,2 ,... ,2−

,seert laimonib deredro rewol lla fo seertbus htiw edon toor a sah eert hcaE :3 ot 0 redro fo seert laimoniBo na ot detcennoc si eert laimonib 3 redro eht ,elpmaxe roF .dethgilhgih neeb evah hcihw 0 dna ,1 ,2 redr

.eert laimonib )ylevitcepser der dna neerg ,eulb sa dethgilhgih(

redro fo eert laimonib A k 2 sah k thgieh ,sedon k.

redro fo eert laimonib a ,erutcurts euqinu sti fo esuaceB k redro fo seert owt morf detcurtsnoc eb nac k 1− ot lartnec si erutaef sihT .eno rehto eht fo toor fo dlihc tsomtfel eht sa meht fo eno gnihcatta yb yllaivirt

eht egrem ehT.spaeh lanoitnevnoc rehto revo egatnavda rojam sti si hcihw ,paeh laimonib a fo noitarepo

rt laimonib a :epahs eht morf semoc eman redro fo ee sah htped ta sedon eeS( . laimoniBtneiciffeoc ).

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 78

moc emiT ytixelp

.eert emoctuo eht fo htap tsomthgir eht ni raeniL htap tsetrohs a si eert emoctuo eht eht fo htap tsomthgir ehT gol naht erom niatnoc t’nac htap tsetrohs A n .sedon

foorP gol naht erom niatnoc nac htap tsetrohs eht fI n tsrif eht neht ,sedon gol + 1 n dluohs slevel2 edulcni 0 2 + 1 + 2 + gol n 2 = gol+1 n - 2 = 1 n - rof ,esac a hcus nI .sedon 1 > n htiw pu dne ew 1 n

> 2 n - .1

spaeH laimoniB .3.7 :

paeh laimoniB a si paeh a ot ralimis paeh yranib si sihT .spaeh owt gnigrem ylkciuq stroppus osla tub eht fo noitatnemelpmi na sa tnatropmi si tI .erutcurts eert laiceps a gnisu yb deveihca paeh elbaegrem

atad tcartsba epyt a si hcihw ,)paeh elbadlem dellac osla( eueuq ytiroirp A .noitarepo egrem gnitroppus fo noitcelloc a sa detnemelpmi si paeh laimonib laimonib seert a htiw erapmoc( paeh yranib a sah hcihw ,

is a fo epahs elgn eert yranib A .) eert laimonib :ylevisrucer denifed si

edon elgnis a si 0 redro fo eert laimonib A redro fo eert laimonib A k t laimonib fo stoor era nerdlihc esohw edon toor a sah sredro fo seer

k ,1− k .)redro siht ni( 0 ,1 ,2 ,... ,2−

,seert laimonib deredro rewol lla fo seertbus htiw edon toor a sah eert hcaE :3 ot 0 redro fo seert laimoniBo na ot detcennoc si eert laimonib 3 redro eht ,elpmaxe roF .dethgilhgih neeb evah hcihw 0 dna ,1 ,2 redr

.eert laimonib )ylevitcepser der dna neerg ,eulb sa dethgilhgih(

redro fo eert laimonib A k 2 sah k thgieh ,sedon k.

redro fo eert laimonib a ,erutcurts euqinu sti fo esuaceB k redro fo seert owt morf detcurtsnoc eb nac k 1− ot lartnec si erutaef sihT .eno rehto eht fo toor fo dlihc tsomtfel eht sa meht fo eno gnihcatta yb yllaivirt

eht egrem ehT.spaeh lanoitnevnoc rehto revo egatnavda rojam sti si hcihw ,paeh laimonib a fo noitarepo

rt laimonib a :epahs eht morf semoc eman redro fo ee sah htped ta sedon eeS( . laimoniBtneiciffeoc ).

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 78

moc emiT ytixelp

.eert emoctuo eht fo htap tsomthgir eht ni raeniL htap tsetrohs a si eert emoctuo eht eht fo htap tsomthgir ehT gol naht erom niatnoc t’nac htap tsetrohs A n .sedon

foorP gol naht erom niatnoc nac htap tsetrohs eht fI n tsrif eht neht ,sedon gol + 1 n dluohs slevel2 edulcni 0 2 + 1 + 2 + gol n 2 = gol+1 n - 2 = 1 n - rof ,esac a hcus nI .sedon 1 > n htiw pu dne ew 1 n

> 2 n - .1

spaeH laimoniB .3.7 :

paeh laimoniB a si paeh a ot ralimis paeh yranib si sihT .spaeh owt gnigrem ylkciuq stroppus osla tub eht fo noitatnemelpmi na sa tnatropmi si tI .erutcurts eert laiceps a gnisu yb deveihca paeh elbaegrem

atad tcartsba epyt a si hcihw ,)paeh elbadlem dellac osla( eueuq ytiroirp A .noitarepo egrem gnitroppus fo noitcelloc a sa detnemelpmi si paeh laimonib laimonib seert a htiw erapmoc( paeh yranib a sah hcihw ,

is a fo epahs elgn eert yranib A .) eert laimonib :ylevisrucer denifed si

edon elgnis a si 0 redro fo eert laimonib A redro fo eert laimonib A k t laimonib fo stoor era nerdlihc esohw edon toor a sah sredro fo seer

k ,1− k .)redro siht ni( 0 ,1 ,2 ,... ,2−

,seert laimonib deredro rewol lla fo seertbus htiw edon toor a sah eert hcaE :3 ot 0 redro fo seert laimoniBo na ot detcennoc si eert laimonib 3 redro eht ,elpmaxe roF .dethgilhgih neeb evah hcihw 0 dna ,1 ,2 redr

.eert laimonib )ylevitcepser der dna neerg ,eulb sa dethgilhgih(

redro fo eert laimonib A k 2 sah k thgieh ,sedon k.

redro fo eert laimonib a ,erutcurts euqinu sti fo esuaceB k redro fo seert owt morf detcurtsnoc eb nac k 1− ot lartnec si erutaef sihT .eno rehto eht fo toor fo dlihc tsomtfel eht sa meht fo eno gnihcatta yb yllaivirt

eht egrem ehT.spaeh lanoitnevnoc rehto revo egatnavda rojam sti si hcihw ,paeh laimonib a fo noitarepo

rt laimonib a :epahs eht morf semoc eman redro fo ee sah htped ta sedon eeS( . laimoniBtneiciffeoc ).

Page 88: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 88

paeh laimonib a fo erutcurtS

ht yfsitas taht seert laimonib fo tes a sa detnemelpmi si paeh laimonib A e seitreporp paeh laimonib :

eht syebo paeh a ni eert laimonib hcaE muminim - ytreporp paeh naht retaerg si edon a fo yek eht :.tnerap sti fo yek eht ot lauqe ro

erehT rehtie eb ylno nac eno ro orez .redro orez gnidulcni ,redro hcae rof seert laimonib

hcihw ,eert eht ni yek tsellams eht sniatnoc eert laimonib hcae fo toor eht taht serusne ytreporp tsrif ehT.paeh eritne eht ot seilppa

a taht seilpmi ytreporp dnoces ehT htiw paeh laimonib n tsom ta fo stsisnoc sedon gol n laimonib 1 + sedon fo rebmun eht yb denimreted yleuqinu era seert eseht fo sredro dna rebmun eht ,tcaf nI .seert n :

eht ni tigid eno ot sdnopserroc eert laimonib hcae yranib rebmun fo noitatneserper n rebmun elpmaxe roF . ,yranib ni 1011 si 31 31 htiw paeh laimonib a suht dna , eerht fo tsisnoc lliw sedon

.)woleb erugif ees( 0 dna ,2 ,3 sredro fo seert laimonib

.syek tcnitsid htiw sedon 31 gniniatnoc paeh laimonib a fo elpmaxE

.3 dna ,2 ,0 sredro htiw seert laimonib eerht fo stsisnoc paeh ehT

noitatnemelpmI

eht fo stoor eht ,seert laimonib eht fo sedon toor eht ot ssecca modnar seriuqer noitarepo on esuaceB a ni derots eb nac seert laimonib tsil deknil eht fo redro gnisaercni yb deredro , .eert

egreM

fo seert laimonib owt fo gnigrem eht si noitarepo tnatropmi tsom dna tselpmis eht ,evoba denoitnem sA degrem eb nac yeht ,seert laimonib fo erutcurts eht ot euD .spaeh laimonib owt nihtiw redro emas eht

lams eht si edon toor rieht sA .yllaivirt rellams eht ,syek owt eht gnirapmoc yb ,eert eht nihtiw tnemele tsel eht fo eertbus a emoceb eert rehto eht nehT .edon toor wen eht semoceb dna ,yek muminim eht si meht fo

spaeh laimonib owt fo gnigrem etelpmoc eht ot cisab si noitarepo sihT .eert denibmoc .

noitcnuf )q ,p(eerTegrem fi yek.toor.q =< yek.toor.p

nruter )q(eerTbuSdda.p esle

nruter )p(eerTbuSdda.q

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 88

paeh laimonib a fo erutcurtS

ht yfsitas taht seert laimonib fo tes a sa detnemelpmi si paeh laimonib A e seitreporp paeh laimonib :

eht syebo paeh a ni eert laimonib hcaE muminim - ytreporp paeh naht retaerg si edon a fo yek eht :.tnerap sti fo yek eht ot lauqe ro

erehT rehtie eb ylno nac eno ro orez .redro orez gnidulcni ,redro hcae rof seert laimonib

hcihw ,eert eht ni yek tsellams eht sniatnoc eert laimonib hcae fo toor eht taht serusne ytreporp tsrif ehT.paeh eritne eht ot seilppa

a taht seilpmi ytreporp dnoces ehT htiw paeh laimonib n tsom ta fo stsisnoc sedon gol n laimonib 1 + sedon fo rebmun eht yb denimreted yleuqinu era seert eseht fo sredro dna rebmun eht ,tcaf nI .seert n :

eht ni tigid eno ot sdnopserroc eert laimonib hcae yranib rebmun fo noitatneserper n rebmun elpmaxe roF . ,yranib ni 1011 si 31 31 htiw paeh laimonib a suht dna , eerht fo tsisnoc lliw sedon

.)woleb erugif ees( 0 dna ,2 ,3 sredro fo seert laimonib

.syek tcnitsid htiw sedon 31 gniniatnoc paeh laimonib a fo elpmaxE

.3 dna ,2 ,0 sredro htiw seert laimonib eerht fo stsisnoc paeh ehT

noitatnemelpmI

eht fo stoor eht ,seert laimonib eht fo sedon toor eht ot ssecca modnar seriuqer noitarepo on esuaceB a ni derots eb nac seert laimonib tsil deknil eht fo redro gnisaercni yb deredro , .eert

egreM

fo seert laimonib owt fo gnigrem eht si noitarepo tnatropmi tsom dna tselpmis eht ,evoba denoitnem sA degrem eb nac yeht ,seert laimonib fo erutcurts eht ot euD .spaeh laimonib owt nihtiw redro emas eht

lams eht si edon toor rieht sA .yllaivirt rellams eht ,syek owt eht gnirapmoc yb ,eert eht nihtiw tnemele tsel eht fo eertbus a emoceb eert rehto eht nehT .edon toor wen eht semoceb dna ,yek muminim eht si meht fo

spaeh laimonib owt fo gnigrem etelpmoc eht ot cisab si noitarepo sihT .eert denibmoc .

noitcnuf )q ,p(eerTegrem fi yek.toor.q =< yek.toor.p

nruter )q(eerTbuSdda.p esle

nruter )p(eerTbuSdda.q

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 88

paeh laimonib a fo erutcurtS

ht yfsitas taht seert laimonib fo tes a sa detnemelpmi si paeh laimonib A e seitreporp paeh laimonib :

eht syebo paeh a ni eert laimonib hcaE muminim - ytreporp paeh naht retaerg si edon a fo yek eht :.tnerap sti fo yek eht ot lauqe ro

erehT rehtie eb ylno nac eno ro orez .redro orez gnidulcni ,redro hcae rof seert laimonib

hcihw ,eert eht ni yek tsellams eht sniatnoc eert laimonib hcae fo toor eht taht serusne ytreporp tsrif ehT.paeh eritne eht ot seilppa

a taht seilpmi ytreporp dnoces ehT htiw paeh laimonib n tsom ta fo stsisnoc sedon gol n laimonib 1 + sedon fo rebmun eht yb denimreted yleuqinu era seert eseht fo sredro dna rebmun eht ,tcaf nI .seert n :

eht ni tigid eno ot sdnopserroc eert laimonib hcae yranib rebmun fo noitatneserper n rebmun elpmaxe roF . ,yranib ni 1011 si 31 31 htiw paeh laimonib a suht dna , eerht fo tsisnoc lliw sedon

.)woleb erugif ees( 0 dna ,2 ,3 sredro fo seert laimonib

.syek tcnitsid htiw sedon 31 gniniatnoc paeh laimonib a fo elpmaxE

.3 dna ,2 ,0 sredro htiw seert laimonib eerht fo stsisnoc paeh ehT

noitatnemelpmI

eht fo stoor eht ,seert laimonib eht fo sedon toor eht ot ssecca modnar seriuqer noitarepo on esuaceB a ni derots eb nac seert laimonib tsil deknil eht fo redro gnisaercni yb deredro , .eert

egreM

fo seert laimonib owt fo gnigrem eht si noitarepo tnatropmi tsom dna tselpmis eht ,evoba denoitnem sA degrem eb nac yeht ,seert laimonib fo erutcurts eht ot euD .spaeh laimonib owt nihtiw redro emas eht

lams eht si edon toor rieht sA .yllaivirt rellams eht ,syek owt eht gnirapmoc yb ,eert eht nihtiw tnemele tsel eht fo eertbus a emoceb eert rehto eht nehT .edon toor wen eht semoceb dna ,yek muminim eht si meht fo

spaeh laimonib owt fo gnigrem etelpmoc eht ot cisab si noitarepo sihT .eert denibmoc .

noitcnuf )q ,p(eerTegrem fi yek.toor.q =< yek.toor.p

nruter )q(eerTbuSdda.p esle

nruter )p(eerTbuSdda.q

Page 89: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 98

no eert kcalb eht ,3>7 ecniS .yek toor eht erapmoc tsrif ,redro emas eht fo seert laimonib owt egrem oTtoor htiw(tfel eht tluser ehT .eertbus a sa )3 edon toor htiw(thgir eht no eert yerg eht ot dehcatta si )7 edon

.3 redro fo eert a si

fo noitarepo ehT gnigrem ni enituorbus a sa desu eb nac dna gnitseretni tsom eht spahrep si spaeh owtor fo stsil ehT .snoitarepo rehto tsom eht ni sa ylralimis ,ylsuoenatlumis desrevart era spaeh htob fo sto

mhtirogla egrem .

redro fo eert a sniatnoc spaeh eht fo eno ylno fI j .paeh degrem eht ot devom si eert siht , spaeh htob fI redro fo eert a niatnoc j redro fo eert eno ot degrem era seert owt eht , j muminim eht taht os 1+ - paeh

redro fo eert rehto emos htiw eert siht egrem ot yrassecen eb retal yam ti taht etoN .deifsitas si ytreporpj spaeh eht fo eno ni tneserp 1+ fo seert eerht tsom ta enimaxe ot deen ew ,mhtirogla eht fo esruoc eht nI .

.)seert rellams owt fo desopmoc eno dna egrem ew spaeh owt eht morf owt( redro yna

o noitatneserper yranib eht ni tib a ot sdnopserroc paeh laimonib a ni eert laimonib hcae esuaceB ,ezis sti f eht fo noitidda yranib eht dna spaeh owt fo gnigrem eht neewteb ygolana na si ereht sezis owt eht fo

thgir morf ,spaeh - ot - owt fo gnigrem a ot sdnopserroc siht ,noitidda gnirud srucco yrrac a revenehW .tfel.egrem eht gnirud seert laimonib

hcaE gol tsom ta redro sah eert n si emit gninnur eht erofereht dna O gol( n .)

noitcnuf )q ,p(egrem elihw ton )(dne.p ( dna ) )(dne.q

))(eerTtnerruc.q ,)(eerTtnerruc.p(eerTegrem = eert fi ton )(ytpme.)(eerTtnerruc.paeh

))(eerTtnerruc.paeh ,eert(eerTegrem = eert )eert(eerTdda.paeh

esle )eert(eerTdda.paeh

)(txen.q )(txen.p )(txen.paeh

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 98

no eert kcalb eht ,3>7 ecniS .yek toor eht erapmoc tsrif ,redro emas eht fo seert laimonib owt egrem oTtoor htiw(tfel eht tluser ehT .eertbus a sa )3 edon toor htiw(thgir eht no eert yerg eht ot dehcatta si )7 edon

.3 redro fo eert a si

fo noitarepo ehT gnigrem ni enituorbus a sa desu eb nac dna gnitseretni tsom eht spahrep si spaeh owtor fo stsil ehT .snoitarepo rehto tsom eht ni sa ylralimis ,ylsuoenatlumis desrevart era spaeh htob fo sto

mhtirogla egrem .

redro fo eert a sniatnoc spaeh eht fo eno ylno fI j .paeh degrem eht ot devom si eert siht , spaeh htob fI redro fo eert a niatnoc j redro fo eert eno ot degrem era seert owt eht , j muminim eht taht os 1+ - paeh

redro fo eert rehto emos htiw eert siht egrem ot yrassecen eb retal yam ti taht etoN .deifsitas si ytreporpj spaeh eht fo eno ni tneserp 1+ fo seert eerht tsom ta enimaxe ot deen ew ,mhtirogla eht fo esruoc eht nI .

.)seert rellams owt fo desopmoc eno dna egrem ew spaeh owt eht morf owt( redro yna

o noitatneserper yranib eht ni tib a ot sdnopserroc paeh laimonib a ni eert laimonib hcae esuaceB ,ezis sti f eht fo noitidda yranib eht dna spaeh owt fo gnigrem eht neewteb ygolana na si ereht sezis owt eht fo

thgir morf ,spaeh - ot - owt fo gnigrem a ot sdnopserroc siht ,noitidda gnirud srucco yrrac a revenehW .tfel.egrem eht gnirud seert laimonib

hcaE gol tsom ta redro sah eert n si emit gninnur eht erofereht dna O gol( n .)

noitcnuf )q ,p(egrem elihw ton )(dne.p ( dna ) )(dne.q

))(eerTtnerruc.q ,)(eerTtnerruc.p(eerTegrem = eert fi ton )(ytpme.)(eerTtnerruc.paeh

))(eerTtnerruc.paeh ,eert(eerTegrem = eert )eert(eerTdda.paeh

esle )eert(eerTdda.paeh

)(txen.q )(txen.p )(txen.paeh

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 98

no eert kcalb eht ,3>7 ecniS .yek toor eht erapmoc tsrif ,redro emas eht fo seert laimonib owt egrem oTtoor htiw(tfel eht tluser ehT .eertbus a sa )3 edon toor htiw(thgir eht no eert yerg eht ot dehcatta si )7 edon

.3 redro fo eert a si

fo noitarepo ehT gnigrem ni enituorbus a sa desu eb nac dna gnitseretni tsom eht spahrep si spaeh owtor fo stsil ehT .snoitarepo rehto tsom eht ni sa ylralimis ,ylsuoenatlumis desrevart era spaeh htob fo sto

mhtirogla egrem .

redro fo eert a sniatnoc spaeh eht fo eno ylno fI j .paeh degrem eht ot devom si eert siht , spaeh htob fI redro fo eert a niatnoc j redro fo eert eno ot degrem era seert owt eht , j muminim eht taht os 1+ - paeh

redro fo eert rehto emos htiw eert siht egrem ot yrassecen eb retal yam ti taht etoN .deifsitas si ytreporpj spaeh eht fo eno ni tneserp 1+ fo seert eerht tsom ta enimaxe ot deen ew ,mhtirogla eht fo esruoc eht nI .

.)seert rellams owt fo desopmoc eno dna egrem ew spaeh owt eht morf owt( redro yna

o noitatneserper yranib eht ni tib a ot sdnopserroc paeh laimonib a ni eert laimonib hcae esuaceB ,ezis sti f eht fo noitidda yranib eht dna spaeh owt fo gnigrem eht neewteb ygolana na si ereht sezis owt eht fo

thgir morf ,spaeh - ot - owt fo gnigrem a ot sdnopserroc siht ,noitidda gnirud srucco yrrac a revenehW .tfel.egrem eht gnirud seert laimonib

hcaE gol tsom ta redro sah eert n si emit gninnur eht erofereht dna O gol( n .)

noitcnuf )q ,p(egrem elihw ton )(dne.p ( dna ) )(dne.q

))(eerTtnerruc.q ,)(eerTtnerruc.p(eerTegrem = eert fi ton )(ytpme.)(eerTtnerruc.paeh

))(eerTtnerruc.paeh ,eert(eerTegrem = eert )eert(eerTdda.paeh

esle )eert(eerTdda.paeh

)(txen.q )(txen.p )(txen.paeh

Page 90: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 09

nib owt gnigrem yb dehsilpmocca si sihT .spaeh laimonib owt fo regrem eht swohs sihT eht fo seert laimo eht fo eno ni eert laimonib eno sa redro emas eht sah eert degrem gnitluser eht fI .eno yb eno redro emas

.niaga degrem era owt esoht neht ,spaeh owt

tresnI

gnitresnI siht ylno gniniatnoc paeh wen a gnitaerc ylpmis yb enod eb nac paeh a ot tnemele wen a gol(O sekat tresni ,egrem eht ot euD .paeh lanigiro eht htiw ti gnigrem neht dna tnemele n revewoh,emit )

na sah ti dezitroma .)tnatsnoc .e.i( )1(O fo emit

muminim dniF

eht dnif oT muminim sihT .seert laimonib eht fo stoor eht gnoma muminim eht dnif ,paeh eht fo tnemele ni ylisae enod eb niaga nac O gol( n tsuj era ereht sa ,emit ) O gol( n yB.enimaxe ot stoor ecneh dna seert )

iatnoc taht eert laimonib eht ot retniop a gnisu eb nac noitarepo siht rof emit eht ,tnemele muminim eht sn ot decuder O .muminim dniF naht rehto noitarepo yna gnimrofrep nehw detadpu eb tsum retniop ehT .)1(

ni enod eb nac sihT O gol( n .noitarepo yna fo emit gninnur eht gnisiar tuohtiw )

muminim eteleD

oT tnemele muminim eht eteled ,eert laimonib sti morf ti evomer ,tnemele siht dnif tsrif ,paeh eht morf yb paeh laimonib etarapes a otni seertbus fo tsil siht mrofsnart nehT .seertbus sti fo tsil a niatbo dna

T .redro tsegral ot tsellams morf meht gniredroer hcae ecniS .paeh lanigiro eht htiw paeh siht egrem neh gol tsom ta sah eert n si paeh wen siht gnitaerc ,nerdlihc O gol( n si spaeh gnigreM .) O gol( n eritne eht os ,)

si noitarepo muminim eteled O gol( n .)

noitcnuf )paeh(niMeteled tsrif.)(seert.paeh = nim )( hcae rof tnerruc ni )(seert.paeh

fi nim < toor.tnerruc neht tnerruc = nim hcae rof eert ni )(seerTbus.nim

)eert(eerTdda.pmt )nim(eerTevomer.paeh )pmt ,paeh(egrem

yek esaerceD

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 09

nib owt gnigrem yb dehsilpmocca si sihT .spaeh laimonib owt fo regrem eht swohs sihT eht fo seert laimo eht fo eno ni eert laimonib eno sa redro emas eht sah eert degrem gnitluser eht fI .eno yb eno redro emas

.niaga degrem era owt esoht neht ,spaeh owt

tresnI

gnitresnI siht ylno gniniatnoc paeh wen a gnitaerc ylpmis yb enod eb nac paeh a ot tnemele wen a gol(O sekat tresni ,egrem eht ot euD .paeh lanigiro eht htiw ti gnigrem neht dna tnemele n revewoh,emit )

na sah ti dezitroma .)tnatsnoc .e.i( )1(O fo emit

muminim dniF

eht dnif oT muminim sihT .seert laimonib eht fo stoor eht gnoma muminim eht dnif ,paeh eht fo tnemele ni ylisae enod eb niaga nac O gol( n tsuj era ereht sa ,emit ) O gol( n yB.enimaxe ot stoor ecneh dna seert )

iatnoc taht eert laimonib eht ot retniop a gnisu eb nac noitarepo siht rof emit eht ,tnemele muminim eht sn ot decuder O .muminim dniF naht rehto noitarepo yna gnimrofrep nehw detadpu eb tsum retniop ehT .)1(

ni enod eb nac sihT O gol( n .noitarepo yna fo emit gninnur eht gnisiar tuohtiw )

muminim eteleD

oT tnemele muminim eht eteled ,eert laimonib sti morf ti evomer ,tnemele siht dnif tsrif ,paeh eht morf yb paeh laimonib etarapes a otni seertbus fo tsil siht mrofsnart nehT .seertbus sti fo tsil a niatbo dna

T .redro tsegral ot tsellams morf meht gniredroer hcae ecniS .paeh lanigiro eht htiw paeh siht egrem neh gol tsom ta sah eert n si paeh wen siht gnitaerc ,nerdlihc O gol( n si spaeh gnigreM .) O gol( n eritne eht os ,)

si noitarepo muminim eteled O gol( n .)

noitcnuf )paeh(niMeteled tsrif.)(seert.paeh = nim )( hcae rof tnerruc ni )(seert.paeh

fi nim < toor.tnerruc neht tnerruc = nim hcae rof eert ni )(seerTbus.nim

)eert(eerTdda.pmt )nim(eerTevomer.paeh )pmt ,paeh(egrem

yek esaerceD

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 09

nib owt gnigrem yb dehsilpmocca si sihT .spaeh laimonib owt fo regrem eht swohs sihT eht fo seert laimo eht fo eno ni eert laimonib eno sa redro emas eht sah eert degrem gnitluser eht fI .eno yb eno redro emas

.niaga degrem era owt esoht neht ,spaeh owt

tresnI

gnitresnI siht ylno gniniatnoc paeh wen a gnitaerc ylpmis yb enod eb nac paeh a ot tnemele wen a gol(O sekat tresni ,egrem eht ot euD .paeh lanigiro eht htiw ti gnigrem neht dna tnemele n revewoh,emit )

na sah ti dezitroma .)tnatsnoc .e.i( )1(O fo emit

muminim dniF

eht dnif oT muminim sihT .seert laimonib eht fo stoor eht gnoma muminim eht dnif ,paeh eht fo tnemele ni ylisae enod eb niaga nac O gol( n tsuj era ereht sa ,emit ) O gol( n yB.enimaxe ot stoor ecneh dna seert )

iatnoc taht eert laimonib eht ot retniop a gnisu eb nac noitarepo siht rof emit eht ,tnemele muminim eht sn ot decuder O .muminim dniF naht rehto noitarepo yna gnimrofrep nehw detadpu eb tsum retniop ehT .)1(

ni enod eb nac sihT O gol( n .noitarepo yna fo emit gninnur eht gnisiar tuohtiw )

muminim eteleD

oT tnemele muminim eht eteled ,eert laimonib sti morf ti evomer ,tnemele siht dnif tsrif ,paeh eht morf yb paeh laimonib etarapes a otni seertbus fo tsil siht mrofsnart nehT .seertbus sti fo tsil a niatbo dna

T .redro tsegral ot tsellams morf meht gniredroer hcae ecniS .paeh lanigiro eht htiw paeh siht egrem neh gol tsom ta sah eert n si paeh wen siht gnitaerc ,nerdlihc O gol( n si spaeh gnigreM .) O gol( n eritne eht os ,)

si noitarepo muminim eteled O gol( n .)

noitcnuf )paeh(niMeteled tsrif.)(seert.paeh = nim )( hcae rof tnerruc ni )(seert.paeh

fi nim < toor.tnerruc neht tnerruc = nim hcae rof eert ni )(seerTbus.nim

)eert(eerTdda.pmt )nim(eerTevomer.paeh )pmt ,paeh(egrem

yek esaerceD

Page 91: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 19

retfA gnisaerced eht gnitaloiv ,tnerap sti fo yek eht naht rellams emoceb yam ti ,tnemele na fo yek ehtmuminim - htiw osla ylbissop dna ,tnerap sti htiw tnemele eht egnahcxe ,esac eht si siht fI .ytreporp paeh

muminim eht litnu ,no os dna ,tnerapdnarg sti - si ytreporp paeh sah eert laimonib hcaE .detaloiv regnol on gol tsom ta thgieh n sekat siht os , O gol( n .emit )

eteleD

oT eteled naht rewol eulav emos ,si taht( ytinifni evitagen ot yek sti esaerced ,paeh eht morf tnemele na.paeh eht ni muminim eht eteled neht dna )paeh eht ni tnemele yna

ecnamrofreP

ni krow snoitarepo gniwollof eht fo llA O gol( n htiw paeh laimonib a no emit ) n :stnemele

paeh eht ot tnemele wen a tresnI yek muminim htiw tnemele eht dniF paeh eht morf yek muminim htiw tnemele eht eteleD tnemele nevig a fo yek esaerceD tnemele nevig eteleD paeh eht morf paeh eno ot spaeh nevig owt egreM

ni enod eb osla nac yek muminim htiw tnemele eht gnidniF O eht ot retniop lanoitidda na gnisu yb )1(.muminim

snoitacilppA noitalumis tneve etercsiD , seueuq ytiroirP

spaeH iccanobiF .4.7 :

A paeh iccanobiF a si erutcurts atad paeh fo noitcelloc a fo gnitsisnoc seert a sah tI . retteb dezitroma a naht emit gninnur paeh laimonib yb depoleved erew spaeh iccanobiF . namderF .L leahciM dna treboR

najraT .E man ehT .7891 ni lanruoj cifitneics a ni dehsilbup tsrif dna 4891 ni semoc paeh iccanobiF fo e morf srebmun iccanobiF .sisylana emit gninnur eht ni desu era hcihw

dniF - ( egrem dna ,yek esaerced ,tresni snoitarepO.emit dezitroma )1(O si muminim ni krow )noinu ni krow muminim eteled dna eteled snoitarepO .emit dezitroma tnatsnoc O gol( n sihT .emit dezitroma )

ecneuqes yna ,erutcurts atad ytpme na morf gnitrats taht snaem fo a dna puorg tsrif eht morf snoitarepo b ekat dluow puorg dnoces eht morf snoitarepo O(a + b gol n fo ecneuqes a hcus paeh laimonib a nI .emit )

ekat dluow snoitarepo O (( a + b ( gol) n nehw paeh laimonib a naht retteb suht si paeh iccanobiF A .emit ))b si yllacitotpmysa naht rellams a.

rof spaeh iccanobiF gnisU seueuq ytiroirp pmysa eht sevorpmi ,smhtirogla tnatropmi fo emit gninnur citot sa hcus mhtirogla s'artskjiD eht gnitupmoc rof htap tsetrohs .hparg a ni sedon owt neewteb

erutcurtS

Page 92: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 29

dekram era secitrev eerhT .3 dna 1 ,0 seerged fo seert eerht sah tI .paeh iccanobiF a fo elpmaxE .1 erugiF.9 si paeh eht fo laitnetop eht eroferehT .)eulb ni nwohs(

tcelloc a si paeh iccanobiF A fo noi seert eht gniyfsitas muminim - ytreporp paeh dlihc a fo yek eht ,si taht , ta syawla si yek muminim eht taht seilpmi sihT .tnerap eht fo yek eht ot lauqe ro naht retaerg syawla si erom si paeh iccanobiF a fo erutcurts eht ,spaeh laimonib htiw derapmoC .seert eht fo eno fo toor eht

seert ehT .elbixelf yreve evah nac paeh eht esac emertxe eht ni dna epahs debircserp a evah ton od ,rennam "yzal" a ni detucexe eb ot snoitarepo emos swolla ytilibixelf sihT .eert etarapes a ni tnemele

od si spaeh gnigrem elpmaxe roF .snoitarepo retal rof krow eht gninoptsop eht gnitanetacnoc yb ylpmis en noitarepo dna ,seert fo stsil owt yek esaerced .eert wen a smrof dna tnerap sti morf edon a stuc semitemos

.emit gninnur derised eht eveihca ot paeh eht ot decudortni eb ot sdeen redro emos tniop emos ta revewoHralucitrap nI edon yreve :wol etiuq tpek era )nerdlihc fo rebmun eht snaem eerged ereh( sedon fo seerged ,

tsom ta eerged sah O gol( n eerged fo edon a ni detoor eertbus a fo ezis eht dna ) k tsael ta si Fk + 2 erehw ,Fk eht si k ht rebmun iccanobiF non hcae fo dlihc eno tsom ta tuc nac ew taht elur eht yb deveihca si sihT . -

toor eht semoceb dna tnerap sti morf tuc eb ot sdeen flesti edon eht ,tuc si dlihc dnoces a nehW .edon tooreert wen a fo noitarepo eht ni desaerced si seert fo rebmun ehT .)woleb ,sdnuob eerged fo foorP ees(muminim eteled .rehtegot deknil era seert erehw ,

yrev enod era srehto elihw emit gnol a ekat nac snoitarepo emos ,erutcurts dexaler a fo tluser a sA eht nI .ylkciuq emit gninnur dezitroma regnol tib elttil a ekat snoitarepo tsaf yrev taht dneterp ew sisylana

a eht morf detcartbus retal neht si emit lanoitidda sihT .od yllautca yeht naht wols fo emit gninnur lautc laitnetop a yb tnemom nevig yna ta derusaem si esu retal rof devas emit fo tnuoma ehT .snoitarepo

yb nevig si paeh iccanobiF a fo laitnetop ehT .noitcnuf

= laitnetoP t 2 + m

erehw t dna ,paeh iccanobiF eht ni seert fo rebmun eht si m si edon A .sedon dekram fo rebmun eht si stoor lla( edon rehtona fo dlihc a edam saw edon siht ecnis tuc saw nerdlihc sti fo eno tsael ta fi dekram

.)dekramnu era

ah paeh a ni eert hcae fo toor eht ,suhT knil ot retal desu eb nac emit fo tinu sihT .derots emit fo tinu eno s enO .derots emit fo stinu owt sah edon dekram hcae ,oslA .0 emit dezitroma ta eert rehtona htiw eert siht

semoceb edon eht ,sneppah siht fI .tnerap sti morf edon eht tuc ot desu eb nac tinu dnoces eht dna toor a.toor rehto yna ni sa ti ni derots niamer lliw emit fo

snoitarepo fo noitatnemelpmI

,ralucric a gnisu deknil era seert lla fo stoor eht ,noitanetacnoc dna noiteled tsaf wolla oT deknil ylbuodtsil fo rebmun sti niatniam ew ,edon hcae roF .tsil a hcus gnisu deknil osla era edon hcae fo nerdlihc ehT .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 29

dekram era secitrev eerhT .3 dna 1 ,0 seerged fo seert eerht sah tI .paeh iccanobiF a fo elpmaxE .1 erugiF.9 si paeh eht fo laitnetop eht eroferehT .)eulb ni nwohs(

tcelloc a si paeh iccanobiF A fo noi seert eht gniyfsitas muminim - ytreporp paeh dlihc a fo yek eht ,si taht , ta syawla si yek muminim eht taht seilpmi sihT .tnerap eht fo yek eht ot lauqe ro naht retaerg syawla si erom si paeh iccanobiF a fo erutcurts eht ,spaeh laimonib htiw derapmoC .seert eht fo eno fo toor eht

seert ehT .elbixelf yreve evah nac paeh eht esac emertxe eht ni dna epahs debircserp a evah ton od ,rennam "yzal" a ni detucexe eb ot snoitarepo emos swolla ytilibixelf sihT .eert etarapes a ni tnemele

od si spaeh gnigrem elpmaxe roF .snoitarepo retal rof krow eht gninoptsop eht gnitanetacnoc yb ylpmis en noitarepo dna ,seert fo stsil owt yek esaerced .eert wen a smrof dna tnerap sti morf edon a stuc semitemos

.emit gninnur derised eht eveihca ot paeh eht ot decudortni eb ot sdeen redro emos tniop emos ta revewoHralucitrap nI edon yreve :wol etiuq tpek era )nerdlihc fo rebmun eht snaem eerged ereh( sedon fo seerged ,

tsom ta eerged sah O gol( n eerged fo edon a ni detoor eertbus a fo ezis eht dna ) k tsael ta si Fk + 2 erehw ,Fk eht si k ht rebmun iccanobiF non hcae fo dlihc eno tsom ta tuc nac ew taht elur eht yb deveihca si sihT . -

toor eht semoceb dna tnerap sti morf tuc eb ot sdeen flesti edon eht ,tuc si dlihc dnoces a nehW .edon tooreert wen a fo noitarepo eht ni desaerced si seert fo rebmun ehT .)woleb ,sdnuob eerged fo foorP ees(muminim eteled .rehtegot deknil era seert erehw ,

yrev enod era srehto elihw emit gnol a ekat nac snoitarepo emos ,erutcurts dexaler a fo tluser a sA eht nI .ylkciuq emit gninnur dezitroma regnol tib elttil a ekat snoitarepo tsaf yrev taht dneterp ew sisylana

a eht morf detcartbus retal neht si emit lanoitidda sihT .od yllautca yeht naht wols fo emit gninnur lautc laitnetop a yb tnemom nevig yna ta derusaem si esu retal rof devas emit fo tnuoma ehT .snoitarepo

yb nevig si paeh iccanobiF a fo laitnetop ehT .noitcnuf

= laitnetoP t 2 + m

erehw t dna ,paeh iccanobiF eht ni seert fo rebmun eht si m si edon A .sedon dekram fo rebmun eht si stoor lla( edon rehtona fo dlihc a edam saw edon siht ecnis tuc saw nerdlihc sti fo eno tsael ta fi dekram

.)dekramnu era

ah paeh a ni eert hcae fo toor eht ,suhT knil ot retal desu eb nac emit fo tinu sihT .derots emit fo tinu eno s enO .derots emit fo stinu owt sah edon dekram hcae ,oslA .0 emit dezitroma ta eert rehtona htiw eert siht

semoceb edon eht ,sneppah siht fI .tnerap sti morf edon eht tuc ot desu eb nac tinu dnoces eht dna toor a.toor rehto yna ni sa ti ni derots niamer lliw emit fo

snoitarepo fo noitatnemelpmI

,ralucric a gnisu deknil era seert lla fo stoor eht ,noitanetacnoc dna noiteled tsaf wolla oT deknil ylbuodtsil fo rebmun sti niatniam ew ,edon hcae roF .tsil a hcus gnisu deknil osla era edon hcae fo nerdlihc ehT .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 29

dekram era secitrev eerhT .3 dna 1 ,0 seerged fo seert eerht sah tI .paeh iccanobiF a fo elpmaxE .1 erugiF.9 si paeh eht fo laitnetop eht eroferehT .)eulb ni nwohs(

tcelloc a si paeh iccanobiF A fo noi seert eht gniyfsitas muminim - ytreporp paeh dlihc a fo yek eht ,si taht , ta syawla si yek muminim eht taht seilpmi sihT .tnerap eht fo yek eht ot lauqe ro naht retaerg syawla si erom si paeh iccanobiF a fo erutcurts eht ,spaeh laimonib htiw derapmoC .seert eht fo eno fo toor eht

seert ehT .elbixelf yreve evah nac paeh eht esac emertxe eht ni dna epahs debircserp a evah ton od ,rennam "yzal" a ni detucexe eb ot snoitarepo emos swolla ytilibixelf sihT .eert etarapes a ni tnemele

od si spaeh gnigrem elpmaxe roF .snoitarepo retal rof krow eht gninoptsop eht gnitanetacnoc yb ylpmis en noitarepo dna ,seert fo stsil owt yek esaerced .eert wen a smrof dna tnerap sti morf edon a stuc semitemos

.emit gninnur derised eht eveihca ot paeh eht ot decudortni eb ot sdeen redro emos tniop emos ta revewoHralucitrap nI edon yreve :wol etiuq tpek era )nerdlihc fo rebmun eht snaem eerged ereh( sedon fo seerged ,

tsom ta eerged sah O gol( n eerged fo edon a ni detoor eertbus a fo ezis eht dna ) k tsael ta si Fk + 2 erehw ,Fk eht si k ht rebmun iccanobiF non hcae fo dlihc eno tsom ta tuc nac ew taht elur eht yb deveihca si sihT . -

toor eht semoceb dna tnerap sti morf tuc eb ot sdeen flesti edon eht ,tuc si dlihc dnoces a nehW .edon tooreert wen a fo noitarepo eht ni desaerced si seert fo rebmun ehT .)woleb ,sdnuob eerged fo foorP ees(muminim eteled .rehtegot deknil era seert erehw ,

yrev enod era srehto elihw emit gnol a ekat nac snoitarepo emos ,erutcurts dexaler a fo tluser a sA eht nI .ylkciuq emit gninnur dezitroma regnol tib elttil a ekat snoitarepo tsaf yrev taht dneterp ew sisylana

a eht morf detcartbus retal neht si emit lanoitidda sihT .od yllautca yeht naht wols fo emit gninnur lautc laitnetop a yb tnemom nevig yna ta derusaem si esu retal rof devas emit fo tnuoma ehT .snoitarepo

yb nevig si paeh iccanobiF a fo laitnetop ehT .noitcnuf

= laitnetoP t 2 + m

erehw t dna ,paeh iccanobiF eht ni seert fo rebmun eht si m si edon A .sedon dekram fo rebmun eht si stoor lla( edon rehtona fo dlihc a edam saw edon siht ecnis tuc saw nerdlihc sti fo eno tsael ta fi dekram

.)dekramnu era

ah paeh a ni eert hcae fo toor eht ,suhT knil ot retal desu eb nac emit fo tinu sihT .derots emit fo tinu eno s enO .derots emit fo stinu owt sah edon dekram hcae ,oslA .0 emit dezitroma ta eert rehtona htiw eert siht

semoceb edon eht ,sneppah siht fI .tnerap sti morf edon eht tuc ot desu eb nac tinu dnoces eht dna toor a.toor rehto yna ni sa ti ni derots niamer lliw emit fo

snoitarepo fo noitatnemelpmI

,ralucric a gnisu deknil era seert lla fo stoor eht ,noitanetacnoc dna noiteled tsaf wolla oT deknil ylbuodtsil fo rebmun sti niatniam ew ,edon hcae roF .tsil a hcus gnisu deknil osla era edon hcae fo nerdlihc ehT .

Page 93: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 39

revoeroM .dekram si edon eht rehtehw dna nerdlihc eht gniniatnoc toor eht ot retniop a niatniam ew.yek muminim

noitarepO muminim dnif ton seod tI .ti gniniatnoc edon eht ot retniop eht peek ew esuaceb laivirt won siA .tnatsnoc si tsoc dezitroma dna lautca htob erofereht ,paeh eht fo laitnetop eht egnahc denoitnem s

,evoba egrem eb nac sihT .spaeh owt eht fo stoor eert fo stsil eht gnitanetacnoc yb ylpmis detnemelpmi si.emit dezitroma tnatsnoc ot niaga gnidael ,egnahc ton seod laitnetop eht dna emit tnatsnoc ni enod

noitarepO tresni en a gnitaerc yb skrow tnatsnoc sekat sihT .egrem gniod dna tnemele eno htiw paeh w suht si tsoc dezitroma ehT .sesaercni seert fo rebmun eht esuaceb ,eno yb sesaercni laitnetop eht dna ,emit

.tnatsnoc llits

.muminim tcartxe fo esahp tsrif retfa 1 erugiF morf paeh iccanobiF saw )muminim eht( 1 yek htiw edoN.seert etarapes sa dedda erew nerdlihc sti dna deteled

noitarepO muminim tcartxe sa emas( muminim eteled toor eht ekat ew tsriF .sesahp eerht ni setarepo )ceb lliw nerdlihc stI .ti evomer dna tnemele muminim eht gniniatnoc rebmun eht fI .seert wen fo stoor emo

saw nerdlihc fo d emit sekat ti , O(d yb sesaercni laitnetop eht dna stoor wen lla ssecorp ot ) d eroferehT .1− si esahp siht fo emit gninnur dezitroma eht O(d = ) O gol( n .)

nim tcartxe retfa 1 erugiF morf paeh iccanobiF deknil era 6 dna 3 sedon ,tsriF .detelpmoc si mumi

.dnuof si muminim wen eht ,yllaniF .2 edon ta detoor eert htiw deknil si tluser eht nehT .rehtegot

htiw toor eht ot retniop eht etadpu ot deen ew ,noitarepo muminim tcartxe eht etelpmoc ot revewoH muminim ot pu eb yam ereht yletanutrofnU .yek n ew esahp dnoces eht nI .kcehc ot deen ew stoor

nehW .eerged emas eht fo stoor rehtegot gniknil ylevisseccus yb stoor fo rebmun eht esaerced erofereht stoor owt u dna v lihc a meht fo eno ekam ew ,eerged emas eht evah eht htiw eno eht taht os rehto eht fo d

a sah toor yreve litnu detaeper si sihT .eno yb esaercni lliw eerged stI .toor eht sniamer yek rellams htgnel fo yarra na esu ew yltneiciffe eerged emas eht fo seert dnif oT .eerged tnereffid O gol( n hcihw ni )

eek ew era owt eht ,eerged emas eht fo dnuof si toor dnoces a nehW .eerged hcae fo toor eno ot retniop a p si emit gninnur lautca ehT .detadpu si yarra eht dna deknil O gol( n + m erehw ) m ta stoor fo rebmun eht si

ew dne eht tA .esahp dnoces eht fo gninnigeb eht tsom ta evah lliw O gol( n a sah hcae esuaceb( stoor ) :si ti retfa ot esahp siht erofeb morf noitcnuf laitnetop eht ni ecnereffid eht eroferehT .)eerged tnereffid

O gol( n ) − m tsom ta neht si emit gninnur dezitroma eht dna , O gol( n + m + ) O gol( n ) − m = O gol( n .) eht ni rotcaf tnatsnoc eht yb edon hcae ni noitresni ta derots laitnetop fo stinu eht pu elacs nac ew ecniS

O(m .esahp siht rof tsoc lautca eht fo trap )

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 39

revoeroM .dekram si edon eht rehtehw dna nerdlihc eht gniniatnoc toor eht ot retniop a niatniam ew.yek muminim

noitarepO muminim dnif ton seod tI .ti gniniatnoc edon eht ot retniop eht peek ew esuaceb laivirt won siA .tnatsnoc si tsoc dezitroma dna lautca htob erofereht ,paeh eht fo laitnetop eht egnahc denoitnem s

,evoba egrem eb nac sihT .spaeh owt eht fo stoor eert fo stsil eht gnitanetacnoc yb ylpmis detnemelpmi si.emit dezitroma tnatsnoc ot niaga gnidael ,egnahc ton seod laitnetop eht dna emit tnatsnoc ni enod

noitarepO tresni en a gnitaerc yb skrow tnatsnoc sekat sihT .egrem gniod dna tnemele eno htiw paeh w suht si tsoc dezitroma ehT .sesaercni seert fo rebmun eht esuaceb ,eno yb sesaercni laitnetop eht dna ,emit

.tnatsnoc llits

.muminim tcartxe fo esahp tsrif retfa 1 erugiF morf paeh iccanobiF saw )muminim eht( 1 yek htiw edoN.seert etarapes sa dedda erew nerdlihc sti dna deteled

noitarepO muminim tcartxe sa emas( muminim eteled toor eht ekat ew tsriF .sesahp eerht ni setarepo )ceb lliw nerdlihc stI .ti evomer dna tnemele muminim eht gniniatnoc rebmun eht fI .seert wen fo stoor emo

saw nerdlihc fo d emit sekat ti , O(d yb sesaercni laitnetop eht dna stoor wen lla ssecorp ot ) d eroferehT .1− si esahp siht fo emit gninnur dezitroma eht O(d = ) O gol( n .)

nim tcartxe retfa 1 erugiF morf paeh iccanobiF deknil era 6 dna 3 sedon ,tsriF .detelpmoc si mumi

.dnuof si muminim wen eht ,yllaniF .2 edon ta detoor eert htiw deknil si tluser eht nehT .rehtegot

htiw toor eht ot retniop eht etadpu ot deen ew ,noitarepo muminim tcartxe eht etelpmoc ot revewoH muminim ot pu eb yam ereht yletanutrofnU .yek n ew esahp dnoces eht nI .kcehc ot deen ew stoor

nehW .eerged emas eht fo stoor rehtegot gniknil ylevisseccus yb stoor fo rebmun eht esaerced erofereht stoor owt u dna v lihc a meht fo eno ekam ew ,eerged emas eht evah eht htiw eno eht taht os rehto eht fo d

a sah toor yreve litnu detaeper si sihT .eno yb esaercni lliw eerged stI .toor eht sniamer yek rellams htgnel fo yarra na esu ew yltneiciffe eerged emas eht fo seert dnif oT .eerged tnereffid O gol( n hcihw ni )

eek ew era owt eht ,eerged emas eht fo dnuof si toor dnoces a nehW .eerged hcae fo toor eno ot retniop a p si emit gninnur lautca ehT .detadpu si yarra eht dna deknil O gol( n + m erehw ) m ta stoor fo rebmun eht si

ew dne eht tA .esahp dnoces eht fo gninnigeb eht tsom ta evah lliw O gol( n a sah hcae esuaceb( stoor ) :si ti retfa ot esahp siht erofeb morf noitcnuf laitnetop eht ni ecnereffid eht eroferehT .)eerged tnereffid

O gol( n ) − m tsom ta neht si emit gninnur dezitroma eht dna , O gol( n + m + ) O gol( n ) − m = O gol( n .) eht ni rotcaf tnatsnoc eht yb edon hcae ni noitresni ta derots laitnetop fo stinu eht pu elacs nac ew ecniS

O(m .esahp siht rof tsoc lautca eht fo trap )

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 39

revoeroM .dekram si edon eht rehtehw dna nerdlihc eht gniniatnoc toor eht ot retniop a niatniam ew.yek muminim

noitarepO muminim dnif ton seod tI .ti gniniatnoc edon eht ot retniop eht peek ew esuaceb laivirt won siA .tnatsnoc si tsoc dezitroma dna lautca htob erofereht ,paeh eht fo laitnetop eht egnahc denoitnem s

,evoba egrem eb nac sihT .spaeh owt eht fo stoor eert fo stsil eht gnitanetacnoc yb ylpmis detnemelpmi si.emit dezitroma tnatsnoc ot niaga gnidael ,egnahc ton seod laitnetop eht dna emit tnatsnoc ni enod

noitarepO tresni en a gnitaerc yb skrow tnatsnoc sekat sihT .egrem gniod dna tnemele eno htiw paeh w suht si tsoc dezitroma ehT .sesaercni seert fo rebmun eht esuaceb ,eno yb sesaercni laitnetop eht dna ,emit

.tnatsnoc llits

.muminim tcartxe fo esahp tsrif retfa 1 erugiF morf paeh iccanobiF saw )muminim eht( 1 yek htiw edoN.seert etarapes sa dedda erew nerdlihc sti dna deteled

noitarepO muminim tcartxe sa emas( muminim eteled toor eht ekat ew tsriF .sesahp eerht ni setarepo )ceb lliw nerdlihc stI .ti evomer dna tnemele muminim eht gniniatnoc rebmun eht fI .seert wen fo stoor emo

saw nerdlihc fo d emit sekat ti , O(d yb sesaercni laitnetop eht dna stoor wen lla ssecorp ot ) d eroferehT .1− si esahp siht fo emit gninnur dezitroma eht O(d = ) O gol( n .)

nim tcartxe retfa 1 erugiF morf paeh iccanobiF deknil era 6 dna 3 sedon ,tsriF .detelpmoc si mumi

.dnuof si muminim wen eht ,yllaniF .2 edon ta detoor eert htiw deknil si tluser eht nehT .rehtegot

htiw toor eht ot retniop eht etadpu ot deen ew ,noitarepo muminim tcartxe eht etelpmoc ot revewoH muminim ot pu eb yam ereht yletanutrofnU .yek n ew esahp dnoces eht nI .kcehc ot deen ew stoor

nehW .eerged emas eht fo stoor rehtegot gniknil ylevisseccus yb stoor fo rebmun eht esaerced erofereht stoor owt u dna v lihc a meht fo eno ekam ew ,eerged emas eht evah eht htiw eno eht taht os rehto eht fo d

a sah toor yreve litnu detaeper si sihT .eno yb esaercni lliw eerged stI .toor eht sniamer yek rellams htgnel fo yarra na esu ew yltneiciffe eerged emas eht fo seert dnif oT .eerged tnereffid O gol( n hcihw ni )

eek ew era owt eht ,eerged emas eht fo dnuof si toor dnoces a nehW .eerged hcae fo toor eno ot retniop a p si emit gninnur lautca ehT .detadpu si yarra eht dna deknil O gol( n + m erehw ) m ta stoor fo rebmun eht si

ew dne eht tA .esahp dnoces eht fo gninnigeb eht tsom ta evah lliw O gol( n a sah hcae esuaceb( stoor ) :si ti retfa ot esahp siht erofeb morf noitcnuf laitnetop eht ni ecnereffid eht eroferehT .)eerged tnereffid

O gol( n ) − m tsom ta neht si emit gninnur dezitroma eht dna , O gol( n + m + ) O gol( n ) − m = O gol( n .) eht ni rotcaf tnatsnoc eht yb edon hcae ni noitresni ta derots laitnetop fo stinu eht pu elacs nac ew ecniS

O(m .esahp siht rof tsoc lautca eht fo trap )

Page 94: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 49

sekat sihT .muminim eht dnif dna stoor gniniamer eht fo hcae kcehc ew esahp driht eht nI O gol( n emit ) erofereht si muminim tcartxe fo emit gninnur dezitroma llarevo ehT .egnahc ton seod laitnetop eht dna

O gol( n .)

dekram owt sti sa llew sa edon sihT .0 ot 9 edon fo yek gnisaerced retfa 1 erugiF morf paeh iccanobiFrt eht morf tuc era srotsecna .stoor wen sa decalp dna 1 ta detoor ee

noitarepO yek esaerced detaloiv semoceb ytreporp paeh eht fi dna yek eht esaerced ,edon eht ekat lliw a ton si tnerap eht fI .tnerap sti morf tuc si edon eht ,)tnerap eht fo yek eht naht rellams si yek wen eht(

,toor eunitnoc eW .dekram si tnerap sti dna llew sa tuc si ti ,ydaerla dekram neeb sah ti fI .dekram si ti yas ,rebmun emos etaerc ew ssecorp eht nI .edon dekramnu na ro toor eht rehtie hcaer ew litnu sdrawpu k ,

ssop tpecxe seert wen eseht fo hcaE .seert wen fo ti toor a sa tub yllanigiro dekram saw eno tsrif eht ylbi tsael ta yb sesaerced laitnetop eht eroferehT .dekram emoceb nac edon enO .dekramnu emoceb lliw k − .2

saw gnittuc eht mrofrep ot emit lautca ehT O(k atsnoc si emit gninnur dezitroma eht erofereht ,) .tn

noitarepo ,yllaniF eteled ot deteled eb ot tnemele eht fo yek eht gnisaerced yb ylpmis detnemelpmi eb nac ot muminim tcartxe llac ew nehT .paeh elohw eht fo muminim eht otni ti gninrut suht ,ytinifni sunim

siht fo emit gninnur dezitroma ehT .ti evomer si noitarepo O gol( n .)

sdnuob eerged fo foorP

eert yna fo )nerdlihc fo rebmun( eerged eht no sdneped paeh iccanobiF a fo ecnamrofrep dezitroma ehT gnieb toor O gol( n erehw ,) n ta detoor eert)bus( eht fo ezis eht taht wohs ew ereH .paeh eht fo ezis eht si

edon yna x eerged fo d tsael ta ezis evah tsum paeh eht ni Fd 2+ erehw , Fk eht si k ht iccanobiF rebmun ehT .

taht )noitcudni yb devorp ylisae( tcaf eht dna siht morf swollof dnuob eerged lla rof

sregetni erehw , evah neht eW( . dna , esab ot gol eht gnikat sevig sedis htob fo ).deriuqer sa

edon yna redisnoC x ( paeh eht ni erehwemos x b ton deen enifeD .)seert niam eht fo eno fo toor eht eezis (x ta detoor eert eht fo ezis eht eb ot ) x fo stnadnecsed fo rebmun eht( x gnidulcni , x evorp eW .)flesti

fo thgieh eht no noitcudni yb x morf htap elpmis tsegnol a fo htgnel eht( x taht ,)fael tnadnecsed a otezis (x) ≥ Fd 2+ erehw , d fo eerged eht si x.

:esac esaB fI x neht ,0 thgieh sah d = dna ,0 ezis (x) = 1 = F2.

:esac evitcudnI esoppuS x eerged dna thgieh evitisop sah d teL .0> y1 , y2 ,... , yd fo nerdlihc eht eb x ,edro ni dexedni fo nerdlihc edam yltnecer tsom erew yeht semit eht fo r x (y1 dna tseilrae eht gnieb yd eht tel dna ,)tsetal c1 , c2 ,... , cd eW .seerged evitcepser rieht eb mialc taht ci ≥ i- hcae rof 2 i 2 htiw ≤i≤d tsuJ :

erofeb yi fo dlihc a edam saw x , y1 ,..., yi 1− fo nerdlihc ydaerla erew x os dna , x tsael ta eerged dah i ta 1− taht neeb evah tsum ti ,lauqe era stoor rieht fo seerged eht nehw ylno denibmoc era seert ecniS .emit taht

yi tsael ta eerged dah osla i- fo dlihc a emaceb ti emit eht ta 1 x t emit taht morF . ,tneserp eht o yi ylno nac eerged tnerruc sti os dna ,)ssecorp gnikram eht yb deetnaraug sa( dlihc eno tsom ta tsol evah ci tsael ta si

i eht sevorp sihT .2− mialc .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 49

sekat sihT .muminim eht dnif dna stoor gniniamer eht fo hcae kcehc ew esahp driht eht nI O gol( n emit ) erofereht si muminim tcartxe fo emit gninnur dezitroma llarevo ehT .egnahc ton seod laitnetop eht dna

O gol( n .)

dekram owt sti sa llew sa edon sihT .0 ot 9 edon fo yek gnisaerced retfa 1 erugiF morf paeh iccanobiFrt eht morf tuc era srotsecna .stoor wen sa decalp dna 1 ta detoor ee

noitarepO yek esaerced detaloiv semoceb ytreporp paeh eht fi dna yek eht esaerced ,edon eht ekat lliw a ton si tnerap eht fI .tnerap sti morf tuc si edon eht ,)tnerap eht fo yek eht naht rellams si yek wen eht(

,toor eunitnoc eW .dekram si tnerap sti dna llew sa tuc si ti ,ydaerla dekram neeb sah ti fI .dekram si ti yas ,rebmun emos etaerc ew ssecorp eht nI .edon dekramnu na ro toor eht rehtie hcaer ew litnu sdrawpu k ,

ssop tpecxe seert wen eseht fo hcaE .seert wen fo ti toor a sa tub yllanigiro dekram saw eno tsrif eht ylbi tsael ta yb sesaerced laitnetop eht eroferehT .dekram emoceb nac edon enO .dekramnu emoceb lliw k − .2

saw gnittuc eht mrofrep ot emit lautca ehT O(k atsnoc si emit gninnur dezitroma eht erofereht ,) .tn

noitarepo ,yllaniF eteled ot deteled eb ot tnemele eht fo yek eht gnisaerced yb ylpmis detnemelpmi eb nac ot muminim tcartxe llac ew nehT .paeh elohw eht fo muminim eht otni ti gninrut suht ,ytinifni sunim

siht fo emit gninnur dezitroma ehT .ti evomer si noitarepo O gol( n .)

sdnuob eerged fo foorP

eert yna fo )nerdlihc fo rebmun( eerged eht no sdneped paeh iccanobiF a fo ecnamrofrep dezitroma ehT gnieb toor O gol( n erehw ,) n ta detoor eert)bus( eht fo ezis eht taht wohs ew ereH .paeh eht fo ezis eht si

edon yna x eerged fo d tsael ta ezis evah tsum paeh eht ni Fd 2+ erehw , Fk eht si k ht iccanobiF rebmun ehT .

taht )noitcudni yb devorp ylisae( tcaf eht dna siht morf swollof dnuob eerged lla rof

sregetni erehw , evah neht eW( . dna , esab ot gol eht gnikat sevig sedis htob fo ).deriuqer sa

edon yna redisnoC x ( paeh eht ni erehwemos x b ton deen enifeD .)seert niam eht fo eno fo toor eht eezis (x ta detoor eert eht fo ezis eht eb ot ) x fo stnadnecsed fo rebmun eht( x gnidulcni , x evorp eW .)flesti

fo thgieh eht no noitcudni yb x morf htap elpmis tsegnol a fo htgnel eht( x taht ,)fael tnadnecsed a otezis (x) ≥ Fd 2+ erehw , d fo eerged eht si x.

:esac esaB fI x neht ,0 thgieh sah d = dna ,0 ezis (x) = 1 = F2.

:esac evitcudnI esoppuS x eerged dna thgieh evitisop sah d teL .0> y1 , y2 ,... , yd fo nerdlihc eht eb x ,edro ni dexedni fo nerdlihc edam yltnecer tsom erew yeht semit eht fo r x (y1 dna tseilrae eht gnieb yd eht tel dna ,)tsetal c1 , c2 ,... , cd eW .seerged evitcepser rieht eb mialc taht ci ≥ i- hcae rof 2 i 2 htiw ≤i≤d tsuJ :

erofeb yi fo dlihc a edam saw x , y1 ,..., yi 1− fo nerdlihc ydaerla erew x os dna , x tsael ta eerged dah i ta 1− taht neeb evah tsum ti ,lauqe era stoor rieht fo seerged eht nehw ylno denibmoc era seert ecniS .emit taht

yi tsael ta eerged dah osla i- fo dlihc a emaceb ti emit eht ta 1 x t emit taht morF . ,tneserp eht o yi ylno nac eerged tnerruc sti os dna ,)ssecorp gnikram eht yb deetnaraug sa( dlihc eno tsom ta tsol evah ci tsael ta si

i eht sevorp sihT .2− mialc .

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 49

sekat sihT .muminim eht dnif dna stoor gniniamer eht fo hcae kcehc ew esahp driht eht nI O gol( n emit ) erofereht si muminim tcartxe fo emit gninnur dezitroma llarevo ehT .egnahc ton seod laitnetop eht dna

O gol( n .)

dekram owt sti sa llew sa edon sihT .0 ot 9 edon fo yek gnisaerced retfa 1 erugiF morf paeh iccanobiFrt eht morf tuc era srotsecna .stoor wen sa decalp dna 1 ta detoor ee

noitarepO yek esaerced detaloiv semoceb ytreporp paeh eht fi dna yek eht esaerced ,edon eht ekat lliw a ton si tnerap eht fI .tnerap sti morf tuc si edon eht ,)tnerap eht fo yek eht naht rellams si yek wen eht(

,toor eunitnoc eW .dekram si tnerap sti dna llew sa tuc si ti ,ydaerla dekram neeb sah ti fI .dekram si ti yas ,rebmun emos etaerc ew ssecorp eht nI .edon dekramnu na ro toor eht rehtie hcaer ew litnu sdrawpu k ,

ssop tpecxe seert wen eseht fo hcaE .seert wen fo ti toor a sa tub yllanigiro dekram saw eno tsrif eht ylbi tsael ta yb sesaerced laitnetop eht eroferehT .dekram emoceb nac edon enO .dekramnu emoceb lliw k − .2

saw gnittuc eht mrofrep ot emit lautca ehT O(k atsnoc si emit gninnur dezitroma eht erofereht ,) .tn

noitarepo ,yllaniF eteled ot deteled eb ot tnemele eht fo yek eht gnisaerced yb ylpmis detnemelpmi eb nac ot muminim tcartxe llac ew nehT .paeh elohw eht fo muminim eht otni ti gninrut suht ,ytinifni sunim

siht fo emit gninnur dezitroma ehT .ti evomer si noitarepo O gol( n .)

sdnuob eerged fo foorP

eert yna fo )nerdlihc fo rebmun( eerged eht no sdneped paeh iccanobiF a fo ecnamrofrep dezitroma ehT gnieb toor O gol( n erehw ,) n ta detoor eert)bus( eht fo ezis eht taht wohs ew ereH .paeh eht fo ezis eht si

edon yna x eerged fo d tsael ta ezis evah tsum paeh eht ni Fd 2+ erehw , Fk eht si k ht iccanobiF rebmun ehT .

taht )noitcudni yb devorp ylisae( tcaf eht dna siht morf swollof dnuob eerged lla rof

sregetni erehw , evah neht eW( . dna , esab ot gol eht gnikat sevig sedis htob fo ).deriuqer sa

edon yna redisnoC x ( paeh eht ni erehwemos x b ton deen enifeD .)seert niam eht fo eno fo toor eht eezis (x ta detoor eert eht fo ezis eht eb ot ) x fo stnadnecsed fo rebmun eht( x gnidulcni , x evorp eW .)flesti

fo thgieh eht no noitcudni yb x morf htap elpmis tsegnol a fo htgnel eht( x taht ,)fael tnadnecsed a otezis (x) ≥ Fd 2+ erehw , d fo eerged eht si x.

:esac esaB fI x neht ,0 thgieh sah d = dna ,0 ezis (x) = 1 = F2.

:esac evitcudnI esoppuS x eerged dna thgieh evitisop sah d teL .0> y1 , y2 ,... , yd fo nerdlihc eht eb x ,edro ni dexedni fo nerdlihc edam yltnecer tsom erew yeht semit eht fo r x (y1 dna tseilrae eht gnieb yd eht tel dna ,)tsetal c1 , c2 ,... , cd eW .seerged evitcepser rieht eb mialc taht ci ≥ i- hcae rof 2 i 2 htiw ≤i≤d tsuJ :

erofeb yi fo dlihc a edam saw x , y1 ,..., yi 1− fo nerdlihc ydaerla erew x os dna , x tsael ta eerged dah i ta 1− taht neeb evah tsum ti ,lauqe era stoor rieht fo seerged eht nehw ylno denibmoc era seert ecniS .emit taht

yi tsael ta eerged dah osla i- fo dlihc a emaceb ti emit eht ta 1 x t emit taht morF . ,tneserp eht o yi ylno nac eerged tnerruc sti os dna ,)ssecorp gnikram eht yb deetnaraug sa( dlihc eno tsom ta tsol evah ci tsael ta si

i eht sevorp sihT .2− mialc .

Page 95: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 59

eht lla fo sthgieh eht ecniS yi fo taht naht ssel yltcirts era x evitcudni eht ylppa nac ew , meht ot sisehtopyh teg ot ezis (yi) ≥ F ic 2+ ≥ F(i 2+)2− = Fi sedon ehT . x dna y1 ot 1 tsael ta etubirtnoc hcae ezis (x evah ew os dna ,)

taht sevorp noitcudni enituor A yna rof rewol derised eht sevig hcihw , no dnuob ezis (x .)

esac tsroW

dednuob si erutcurts ytpme na htiw gnitrats snoitarepo fo ecneuqes a fo emit gninnur latot eht hguohtlA ni( etelpmoc ot gnol yrev ekat nac ecneuqes eht ni snoitarepo )wef yrev( emos ,evoba nevig sdnuob eht yb

aenil evah muminim eteled dna eteled ralucitrap nosaer siht roF .)esac tsrow eht ni emit gninnur r rof etairporppa eb ton yam serutcurts atad dezitroma rehto dna spaeh iccanobiF laer - smetsys emit si tI .

c ot elbissop sah paeh iccanobiF eht sa ecnamrofrep esac tsrow emas eht hcihw erutcurts atad a etaer.ecnamrofrep dezitroma ]3[ tsom ni lufesu ton si ti os ,detacilpmoc yrev si erutcurts gnitluser eht revewoH

.sesac lacitcarp

spaeh gniriaP .5.7 fo epyt a era spaeh gniriaP paeh erutcurts atad tnellecxe dna noitatnemelpmi elpmis ylevitaler htiw

lacitcarp dezitroma evorp sah ti ,revewoH .ecnamrofrep esicerp eht enimreted ot tluciffid yrev n.spaeh gniriap fo emit gninnur citotpmysa

era spaeh gniriaP deredro paeh seert yawitlum elpmis ylevitaler si snoitarepo paeh suoirav eht gnibircseD .nim a emussa ew gniwollof eht ni( - :)paeh

dnif - nim .paeh eht fo tnemele pot eht nruter ylpmis : egrem oc : regral eht ,tluser eht fo toor eht sniamer rellams eht ,stnemele toor owt eht erapm

.toor siht fo dlihc a sa dedneppa si eertbus sti dna tnemele tresni dna tnemele detresni eht rof paeh wen a etaerc : egrem .paeh lanigiro eht otni esaerced - yek r :)lanoitpo( neht desaerced eb ot yek eht ta detoor eertbus eht evome egrem htiw ti

.paeh eht eteled - nim dna toor eht evomer : egrem .deyolpme era seigetarts suoiraV .seertbus sti

rep emit dezitroma ehT eteled - nim si O gol( n). ]1[ snoitarepo ehT dnif - nim , egrem dna , tresni ekat

O )1( emit dezitroma ]2[ dna esaerced - yek sekat .emit dezitroma ]3[ derF nam rep emit dezitroma eht taht devorp esaerced - yek tsael ta si golgol(Ω n). ]4[ ssel era yeht ,si tahT

naht tneiciffe spaeh iccanobiF mrofrep hcihw , esaerced - yek ni O )1( .emit dezitroma

noitatnemelpmI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 59

eht lla fo sthgieh eht ecniS yi fo taht naht ssel yltcirts era x evitcudni eht ylppa nac ew , meht ot sisehtopyh teg ot ezis (yi) ≥ F ic 2+ ≥ F(i 2+)2− = Fi sedon ehT . x dna y1 ot 1 tsael ta etubirtnoc hcae ezis (x evah ew os dna ,)

taht sevorp noitcudni enituor A yna rof rewol derised eht sevig hcihw , no dnuob ezis (x .)

esac tsroW

dednuob si erutcurts ytpme na htiw gnitrats snoitarepo fo ecneuqes a fo emit gninnur latot eht hguohtlA ni( etelpmoc ot gnol yrev ekat nac ecneuqes eht ni snoitarepo )wef yrev( emos ,evoba nevig sdnuob eht yb

aenil evah muminim eteled dna eteled ralucitrap nosaer siht roF .)esac tsrow eht ni emit gninnur r rof etairporppa eb ton yam serutcurts atad dezitroma rehto dna spaeh iccanobiF laer - smetsys emit si tI .

c ot elbissop sah paeh iccanobiF eht sa ecnamrofrep esac tsrow emas eht hcihw erutcurts atad a etaer.ecnamrofrep dezitroma ]3[ tsom ni lufesu ton si ti os ,detacilpmoc yrev si erutcurts gnitluser eht revewoH

.sesac lacitcarp

spaeh gniriaP .5.7 fo epyt a era spaeh gniriaP paeh erutcurts atad tnellecxe dna noitatnemelpmi elpmis ylevitaler htiw

lacitcarp dezitroma evorp sah ti ,revewoH .ecnamrofrep esicerp eht enimreted ot tluciffid yrev n.spaeh gniriap fo emit gninnur citotpmysa

era spaeh gniriaP deredro paeh seert yawitlum elpmis ylevitaler si snoitarepo paeh suoirav eht gnibircseD .nim a emussa ew gniwollof eht ni( - :)paeh

dnif - nim .paeh eht fo tnemele pot eht nruter ylpmis : egrem oc : regral eht ,tluser eht fo toor eht sniamer rellams eht ,stnemele toor owt eht erapm

.toor siht fo dlihc a sa dedneppa si eertbus sti dna tnemele tresni dna tnemele detresni eht rof paeh wen a etaerc : egrem .paeh lanigiro eht otni esaerced - yek r :)lanoitpo( neht desaerced eb ot yek eht ta detoor eertbus eht evome egrem htiw ti

.paeh eht eteled - nim dna toor eht evomer : egrem .deyolpme era seigetarts suoiraV .seertbus sti

rep emit dezitroma ehT eteled - nim si O gol( n). ]1[ snoitarepo ehT dnif - nim , egrem dna , tresni ekat

O )1( emit dezitroma ]2[ dna esaerced - yek sekat .emit dezitroma ]3[ derF nam rep emit dezitroma eht taht devorp esaerced - yek tsael ta si golgol(Ω n). ]4[ ssel era yeht ,si tahT

naht tneiciffe spaeh iccanobiF mrofrep hcihw , esaerced - yek ni O )1( .emit dezitroma

noitatnemelpmI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 59

eht lla fo sthgieh eht ecniS yi fo taht naht ssel yltcirts era x evitcudni eht ylppa nac ew , meht ot sisehtopyh teg ot ezis (yi) ≥ F ic 2+ ≥ F(i 2+)2− = Fi sedon ehT . x dna y1 ot 1 tsael ta etubirtnoc hcae ezis (x evah ew os dna ,)

taht sevorp noitcudni enituor A yna rof rewol derised eht sevig hcihw , no dnuob ezis (x .)

esac tsroW

dednuob si erutcurts ytpme na htiw gnitrats snoitarepo fo ecneuqes a fo emit gninnur latot eht hguohtlA ni( etelpmoc ot gnol yrev ekat nac ecneuqes eht ni snoitarepo )wef yrev( emos ,evoba nevig sdnuob eht yb

aenil evah muminim eteled dna eteled ralucitrap nosaer siht roF .)esac tsrow eht ni emit gninnur r rof etairporppa eb ton yam serutcurts atad dezitroma rehto dna spaeh iccanobiF laer - smetsys emit si tI .

c ot elbissop sah paeh iccanobiF eht sa ecnamrofrep esac tsrow emas eht hcihw erutcurts atad a etaer.ecnamrofrep dezitroma ]3[ tsom ni lufesu ton si ti os ,detacilpmoc yrev si erutcurts gnitluser eht revewoH

.sesac lacitcarp

spaeh gniriaP .5.7 fo epyt a era spaeh gniriaP paeh erutcurts atad tnellecxe dna noitatnemelpmi elpmis ylevitaler htiw

lacitcarp dezitroma evorp sah ti ,revewoH .ecnamrofrep esicerp eht enimreted ot tluciffid yrev n.spaeh gniriap fo emit gninnur citotpmysa

era spaeh gniriaP deredro paeh seert yawitlum elpmis ylevitaler si snoitarepo paeh suoirav eht gnibircseD .nim a emussa ew gniwollof eht ni( - :)paeh

dnif - nim .paeh eht fo tnemele pot eht nruter ylpmis : egrem oc : regral eht ,tluser eht fo toor eht sniamer rellams eht ,stnemele toor owt eht erapm

.toor siht fo dlihc a sa dedneppa si eertbus sti dna tnemele tresni dna tnemele detresni eht rof paeh wen a etaerc : egrem .paeh lanigiro eht otni esaerced - yek r :)lanoitpo( neht desaerced eb ot yek eht ta detoor eertbus eht evome egrem htiw ti

.paeh eht eteled - nim dna toor eht evomer : egrem .deyolpme era seigetarts suoiraV .seertbus sti

rep emit dezitroma ehT eteled - nim si O gol( n). ]1[ snoitarepo ehT dnif - nim , egrem dna , tresni ekat

O )1( emit dezitroma ]2[ dna esaerced - yek sekat .emit dezitroma ]3[ derF nam rep emit dezitroma eht taht devorp esaerced - yek tsael ta si golgol(Ω n). ]4[ ssel era yeht ,si tahT

naht tneiciffe spaeh iccanobiF mrofrep hcihw , esaerced - yek ni O )1( .emit dezitroma

noitatnemelpmI

Page 96: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 69

fo tsil ytpme ylbissop a dna tnemele toor a fo gnitsisnoc riap a ro ,paeh ytpme na rehtie si paeh gniriap A era tsil eht ni spaehbus eht fo stnemele toor eht lla taht seriuqer ytreporp gniredro paeh ehT .spaeh gniriap

fo tnemele toor neht taht rellams ton lanoitcnuf ylerup a semussa noitpircsed gniwollof ehT .paeh eht eht troppus ton seod taht paeh esaerced - yek .noitarepo

epyt )]]melE[paeHgniriaP[tsiL :spaehbus ,melE :mele(paeH | ytpmE = ]melE[paeHgniriaP

snoitarepO

dnif - nim

noitcnuf ehT dnif - nim :paeh eht fo tnemele toor eht snruter ylpmis

noitcnuf dnif - )paeh(nim fi ytpmE == paeh rorre

esle nruter mele.paeh

:egrem

eht sah taht denruter si paeh wen a esiwrehto ,paeh rehto eht snruter paeh ytpme na htiw gnigreMe toor owt eht fo muminim tsil eht ot toor regral eht htiw paeh eht sdda tsuj dna tnemele toor sti sa stnemel

:spaehbus fo

noitcnuf )2paeh ,1paeh(egrem fi ytpmE == 1paeh nruter 2paeh

fisle ytpmE == 2paeh nruter 1paeh

fiesle mele.2paeh < mele.1paeh nruter )spaehbus.1paeh :: 2paeh ,mele.1paeh(paeH

esle nruter )spaehbus.2paeh :: 1paeh ,mele.2paeh(paeH

I :tresn

gniniatnoc paeh wen a htiw paeh eht egrem ot si paeh a otni tnemele na tresni ot yaw tseisae ehT:spaehbus fo tsil ytpme na dna tnemele siht tsuj

noitcnuf )paeh ,mele(tresni nruter )paeh ,)][ ,mele(paeH(egrem

eteled - :nim

non ylno ehT - ehT .paeh eht morf tnemele muminim eht fo noiteled eht si noitarepo latnemadnuf laivirtg taht pets eht si siht( sriap ni spaehbus eht segrem tsrif ygetarts dradnats )eman sti erutcurtsatad siht eva

:tfel ot thgir morf spaeh fo tsil gnitluser eht segrem neht dna thgir ot tfel morf

noitcuf eteled - )paeh(nim fi ytpmE == paeh

Page 97: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 79

rorre fisle 0 == )spaehbus.paeh(htgnel nruter ytpmE

fisle 1 == )spaehbus.paeh(htgnel nruter ]0[spaehbus.paeh

esle nruter egrem - )spaehbus.paeh(sriap

noitcnuf yrailixua eht sesu sihT egrem - sriap :

noitcnuf egrem - )l(sriap fi 0 == )l(htgnel nruter ytpmE

fisle 1 == )l(htgnel nruter ]0[l

esle nruter egrem ,)]1[l ,]0[l(egrem(egrem - ))] ..2[l(sriap

owt debircsed eht tnemelpmi deedni seod siht tahT - tfel ssap - ot - thgir neht thgir - ot - ygetarts gnigrem tfel:noitcuder siht morf nees eb nac

egrem - )]7H ,6H ,5H ,4H ,3H ,2H ,1H[(sriap m ,)2H ,1H(egrem(egrem >= egre - ))]7H ,6H ,5H ,4H ,3H[(sriap

tsil eht fo tser eht neht ,21H ot 2H dna 1H egrem # (egrem >= 21H egrem ,)4H ,3H(egrem(egrem , - )))]7H ,6H ,5H[(sriap

tsil eht fo tser eht neht ,43H ot 4H dna 3H egrem # (egrem ,21H(egrem >= 43H ,)6H ,5H(egrem(egrem , egrem - ))))]7H[(sriap

tsil eht fo tser eht neht ,65H ot 5H dna 5H egrem # (egrem ,43H(egrem ,21H(egrem >= 65H )))7H ,

765H gnivig ,spaeh gnitluser owt tsal eht egrem ,noitcerid hctiws # ,43H(egrem ,21H(egrem >= 765H ))

76543H gnivig ,spaeh gnitluser owt tsal eht egrem # ,21H(egrem >= 76543H )

tser eht gnigrem fo tluser eht htiw riap degrem tsrif eht egrem ,yllanif # >= 7654321H

.6.7 SNOITSEUQ DEDNEMMOCER eueuq ytiroirp a enifeD .1

elbuoD( euqeD a enifeD .2 - dnE )eueuQ de

?eueuq ytiroirP rof deen eht si tahW .3

?seueuq ytiroirp fo snoitacilppa eht era tahW .4

?spaeh laimonib era tahW .5

thgieh eht nialpxE .6 - .seert tsitfel desaib

Page 98: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 89

TINU – 8 : SEERT HCRAES YRANIB TNEICIFFE seerT hcraeS yraniB lamitpO .1.8 :

lamitpo nA sedon eht hcihw rof eert hcraes yranib a si eert hcraes yranib taht hcus slevel no degnarra eramuminim si tsoc eert eht . ew ,seert hcraes yranib lamitpo fo noitatneserp retteb a fo esoprup eht roF lliw

evah hcihw ,”seert hcraes yranib dednetxe“ redisnoc rieht ta derots syek eht ”n“ esoppuS .sedon lanretnia fo sedon lanretni eht ta derots era n k , … ,2k ,1k syek era syek eht taht demussa si tI .eert hcraes yranib

taht os ,redro detros ni nevig f deniatbo si eert hcraes yranib dednetxe nA .nk < … < 2k <1k eht morhcraes yranib eht ni detacidni sa sedon lanimret sti fo hcae ot sedon rosseccus gnidda yb eert gniwollof

:serauqs yb erugif

:eert dednetxe eht nI

tneserper sedon lanimret esehT .sedon lanimret tneserper serauqs eht eht fo sehcraes lufsseccusnurt dne ton did sehcraes ehT .seulav yek rof ee yek tneserper yeht esuaceb ,si taht ,yllufsseccus

yllautca ton era taht seulav ;eert eht ni derots derots syek lautca eht era eseht ;sedon lanretni tneserper sedon dnuor eht ;eert eht ni vitaler eht taht gnimussa dessecca si eulav yek hcae hcihw htiw ycneuqerf e nac sthgiew ,nwonk si

… 1p( eert dednetxe eht fo edon hcae ot dengissa eb seicneuqerf evitaler eht tneserper yehT .)6phcae ta gnitanimret sehcraes fo .sehcraes lufsseccus eht kram yeht ,si taht ,edon

t fI :rucco nac sesac 2 ,eert eht ni yek ralucitrap a sehcraes resu eh

1 – ehT ;detnemercni si ’p‘ thgiew gnidnopserroc eht os ,dnuof si yek 2 – ehT .detnemercni si eulav ’q‘ gnidnopserroc eht os ,dnuof ton si yek

eht ni edon lanimret eht :NOITAZILARENEG rosseccus tfel eht si taht eert dednetxe eb nac 1k fo

era dna derots ton era taht seulav yek lla gnitneserper sa deterpretni lanimret eht ,ylralimiS .1k naht sselthgir eht si taht eert dednetxe eht ni edon ton seulav yek lla stneserper ,nk fo rosseccus eert eht ni derots

retaerg era taht ik dna ik neewteb desseccus si taht edon lanimret ehT .nk naht - redroni na ni 1 lasrevart ik dna ik neewteb eil taht derots ton seulav yek lla stneserper - .1

eg ot si eert hcraes yranib lamitpo na dnif ot yaw suoivbo nA elbissop hcae etaren rof eert hcraes yranib

taht peek dna ,htgnel htap dethgiew eht etaluclac ,syek eht .htgnel htap dethgiew tsellams eht htiw eertelbissop lla hguorht hcraes sihT sworg seert hcus fo rebmun eht ecnis ,elbisaef ton si snoitulos

aitnenopxe htiw yll .”n“

yna fo scitsiretcarahc eht redisnoC .mhtirogla evisrucer a eb dluow evitanretla nA esruoc fO .eert lamitpotsum seertbus htoB .seertbus owt dna toor a sah ti tcepser htiw seert hcraes yranib lamitpo eb sevlesmeht

.sthgiew dna syek rieht ot F .eert hcraes yranib a eb tsum eert hcraes yranib yna fo eertbus yna ,tsri,dnoceS .lamitpo eb osla tsum seertbus eht fo toor eht rof setadidnac sa syek elbissop ”n“ era ereht ecniS

,eert lamitpo eht didnac hcae roF .lla meht yrt tsum noitulos evisrucer eht syek lla ,toor sa yek eta naht ssel

Page 99: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 99

ti naht retaerg syek lla elihw eertbus tfel sti ni raeppa tsum yek taht .eertbus thgir sti ni raeppa tsumeseht no desab mhtirogla evisrucer eht gnitatS :snoitaton emos seriuqer snoitavresbo

amitpo eht setoned )j ,i(TSBO ,ik syek eht gniniatnoc eert hcraes yranib l ;jk ,… ,1+ik

)j ,i(TSBO rof xirtam thgiew eht setoned j ,iW :alumrof gniwollof eht gnisu denifed eb nac j ,iW

__

0 ,j ,iC )j ,i(TSBO rof xirtam tsoc eht setoned n ≤ j ≤ i ≤ ,ylevisrucer denifed eb nac j ,iC :rennam gniwollof eht ni

j ,iW = i ,iC k<inim + j ,iW = j ,iC k ,iC(j≤ - )j ,kC + 1

0 ,j ,iR )j ,i(TSBO rof xirtam toor eht setoned n ≤ j ≤ i ≤ muminim a niatbo ew hcihw rof k fo eulav eht ot j ,iR noitaton eht gningissA eht ,snoitaler evoba eht ni

lamitpo hcae dna )n ,0(TSBO si eert hcraes yranib eht seertbus sa dna jiRk toor eht sah )j ,i(TSBO eertbusyb detoned seert k ,i(TSBO - .)j ,k(TSBO dna )1

iq sthgiew eht evlovni lliw )j ,i(TSBO* - .jq ,jp ,… ,iq ,ip ,1

.deriuqer ton era seertbus lamitpo elbissop llA fo tsisnoc era taht esohT era taht syek fo secneuqeseht ni yek tsellams eht fo srosseccus etaidemmi .syek eht rof redro detros eht ni srosseccus ,eertbus ehT

mottob - seertbus lamitpo deriuqer tsellams eht lla setareneg hcaorppa pu lams txen lla neht ,tsrif dna ,tseleht lla gnivlovni noitulos lanif eht litnu no os ot ssecca seriuqer mhtirogla eht ecniS .dnuof si sthgiew

dethgiew s’eertbus hcae rieht diova ot deniater eb osla tsum shtgnel htap dethgiew eseht ,htgnel htap ni derots eb lliw yehT .noitaluclacer fo toor eht ,yllaniF .’W‘ xirtam thgiew eht eb osla tsum eertbus hcae

.’R‘ xirtam toor eht ni ecnerefer rof derots

eert hcraes yranib lamitpo na sdliub noitcnuf gniwollof ehT

)j ,i ,R(TCURTSNOC NOITCNUF nigeb

)j ,i( delebal N edon lanretni wen a dliub* k )j ,i( R _

neht k = i fi )i ,i( delebal ’N edon fael wen a dliub*

esle )k ,i ,R(TCURTSNOC _ ’N* N edon fo dlihc tfel eht si ’N*

j( = k fi – neht )1 )j ,j( delebal ’’N edon fael wen a dliub*

esle )j ,1 + k ,R(TCURTSNOC _ ’’N*

don fo dlihc thgir eht si ’’N* N e N nruter

dne

.2.8 seerT LVA

Page 100: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 001

snoitinifeD

retfa demaN .sidnaL dna ,iiksleV ,nosledA

thgieh fo seerT O gol( n eb ot dias era ) decnalab eht hcihw ni esac laiceps a fo tsisnoc seert LVA . dna ,tresni ,hcraes ot desu eb nac seert decnalaB .thgieh rieht ni 1 tsom ta yb reffid edon hcae fo seertbus

yrartibra eteled ni syek O gol( n thgieh ,tsartnoc nI .emit ) - non no yler seert tsitfel desaib - ot seert decnalabdeeps - .seueuq ytiroirp ni snoiteled dna snoitresni pu

thgieH

:mialC .decnalab era seert LVA

.foorP teL Nh h htped fo eert LVA na ni sedon fo rebmun eht etoned

Nh > Nh-1 + Nh-2 1 +

> 2Nh-2 1 +

> 2 + 1(2 + 1 Nh-4)

2 + 2 + 1 = 2N h-4

> 2 + 2 + 1 2 2 + 3N h-6

...

> 2 + 2 + 1 2 2 + 3 + ... 2 + /h 2

2 = /h 2 – 1

,ecneH

2 /h 2 - 1 < n

/h 2 < gol 2( n )1 +

h < gol 2 2( n )1 +

1 fo dnuob rethgit eht seilpmi ,yroeht srebmun iccanobiF no desab ,sisylana luferac erom A . gol 44 2( n + .)2

Page 101: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 101

snoitatoR

LL

RR

RL

LR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 101

snoitatoR

LL

RR

RL

LR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 101

snoitatoR

LL

RR

RL

LR

Page 102: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 201

LL &

RL LL

snoiteleD dna snoitresnI

tcerroc ot snoitator yb dewollof dna ,seert hcraes yranib ni sa demrofrep era snoiteled dna snoitresnI fo esac eht nI .tneiciffus si noitator eno ,snoitresni fo esac eht nI .seert emoctuo eht ni secnalabmi

,snoiteled O gol( n f dedeen era tsom ta snoitator ) eht drawot pu gniog ycnapercsid fo tniop tsrif eht mor .toor

4 eteleD

’2‘ htiw noitator LL a seilpmi ’3‘ ta ecnalabmI

.’8‘ htiw noitator RR a seilpmi ’5‘ ta ecnalabmI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 201

LL &

RL LL

snoiteleD dna snoitresnI

tcerroc ot snoitator yb dewollof dna ,seert hcraes yranib ni sa demrofrep era snoiteled dna snoitresnI fo esac eht nI .tneiciffus si noitator eno ,snoitresni fo esac eht nI .seert emoctuo eht ni secnalabmi

,snoiteled O gol( n f dedeen era tsom ta snoitator ) eht drawot pu gniog ycnapercsid fo tniop tsrif eht mor .toor

4 eteleD

’2‘ htiw noitator LL a seilpmi ’3‘ ta ecnalabmI

.’8‘ htiw noitator RR a seilpmi ’5‘ ta ecnalabmI

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 201

LL &

RL LL

snoiteleD dna snoitresnI

tcerroc ot snoitator yb dewollof dna ,seert hcraes yranib ni sa demrofrep era snoiteled dna snoitresnI fo esac eht nI .tneiciffus si noitator eno ,snoitresni fo esac eht nI .seert emoctuo eht ni secnalabmi

,snoiteled O gol( n f dedeen era tsom ta snoitator ) eht drawot pu gniog ycnapercsid fo tniop tsrif eht mor .toor

4 eteleD

’2‘ htiw noitator LL a seilpmi ’3‘ ta ecnalabmI

.’8‘ htiw noitator RR a seilpmi ’5‘ ta ecnalabmI

Page 103: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 301

3.8 . deR - seerT kcalb seitreporP

hcihw ni eert hcraes yranib A

kcalb deroloc si toor ehT sedon kcalb fo rebmun eht no eerga sevael eht ot toor eht morf shtap eht llA der deroloc sedon evitucesnoc owt niatnoc yam fael a ot toor eht morf htap oN

loc kcalb fo stoor htiw seertbus sa detaert era edon a fo seertbus ytpmE .ro

noitaler ehT n > 2 /h 2 - dnuob eht seilpmi 1 h < gol 2 2( n .)1 +

snoitresnI

seert hcraes yranib ni enod si ti yaw eht edon wen eht tresnI der edon eht roloC der eht rof sesira ycnapercsid a fI - .ycnapercsid fo epyt eht ot gnidrocca eert eht xif ,eert kcalb

si ycnapercsid fo epyt ehT .roloc der a gnivah htob dlihc a dna tnerap a morf tluser nac ycnapercsid Aeht fo noitacol eht yb denimreted eht fo gnilbis eht fo roloc eht dna ,tnerap dnarg sti ot tcepser htiw edon

.tnerap

eht hcihw ni seicnapercsiD .roloc ni segnahc yb dexif era ,der si gnilbis eht hcihw ni seicnapercsiDLVA hguorht dexif era ,kcalb era sgnilbis - .snoitator ekil

ni segnahC noitator eno tsom ta ,dnah rehto eht nO .toor eht drawot pu melborp eht etagaporp yam roloc .ycnapercsid a gnixif rof tneiciffus si

rLL

kcalb ot detniaper eb dluohs ti neht ,toor eht si ’A‘ fi

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 301

3.8 . deR - seerT kcalb seitreporP

hcihw ni eert hcraes yranib A

kcalb deroloc si toor ehT sedon kcalb fo rebmun eht no eerga sevael eht ot toor eht morf shtap eht llA der deroloc sedon evitucesnoc owt niatnoc yam fael a ot toor eht morf htap oN

loc kcalb fo stoor htiw seertbus sa detaert era edon a fo seertbus ytpmE .ro

noitaler ehT n > 2 /h 2 - dnuob eht seilpmi 1 h < gol 2 2( n .)1 +

snoitresnI

seert hcraes yranib ni enod si ti yaw eht edon wen eht tresnI der edon eht roloC der eht rof sesira ycnapercsid a fI - .ycnapercsid fo epyt eht ot gnidrocca eert eht xif ,eert kcalb

si ycnapercsid fo epyt ehT .roloc der a gnivah htob dlihc a dna tnerap a morf tluser nac ycnapercsid Aeht fo noitacol eht yb denimreted eht fo gnilbis eht fo roloc eht dna ,tnerap dnarg sti ot tcepser htiw edon

.tnerap

eht hcihw ni seicnapercsiD .roloc ni segnahc yb dexif era ,der si gnilbis eht hcihw ni seicnapercsiDLVA hguorht dexif era ,kcalb era sgnilbis - .snoitator ekil

ni segnahC noitator eno tsom ta ,dnah rehto eht nO .toor eht drawot pu melborp eht etagaporp yam roloc .ycnapercsid a gnixif rof tneiciffus si

rLL

kcalb ot detniaper eb dluohs ti neht ,toor eht si ’A‘ fi

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 301

3.8 . deR - seerT kcalb seitreporP

hcihw ni eert hcraes yranib A

kcalb deroloc si toor ehT sedon kcalb fo rebmun eht no eerga sevael eht ot toor eht morf shtap eht llA der deroloc sedon evitucesnoc owt niatnoc yam fael a ot toor eht morf htap oN

loc kcalb fo stoor htiw seertbus sa detaert era edon a fo seertbus ytpmE .ro

noitaler ehT n > 2 /h 2 - dnuob eht seilpmi 1 h < gol 2 2( n .)1 +

snoitresnI

seert hcraes yranib ni enod si ti yaw eht edon wen eht tresnI der edon eht roloC der eht rof sesira ycnapercsid a fI - .ycnapercsid fo epyt eht ot gnidrocca eert eht xif ,eert kcalb

si ycnapercsid fo epyt ehT .roloc der a gnivah htob dlihc a dna tnerap a morf tluser nac ycnapercsid Aeht fo noitacol eht yb denimreted eht fo gnilbis eht fo roloc eht dna ,tnerap dnarg sti ot tcepser htiw edon

.tnerap

eht hcihw ni seicnapercsiD .roloc ni segnahc yb dexif era ,der si gnilbis eht hcihw ni seicnapercsiDLVA hguorht dexif era ,kcalb era sgnilbis - .snoitator ekil

ni segnahC noitator eno tsom ta ,dnah rehto eht nO .toor eht drawot pu melborp eht etagaporp yam roloc .ycnapercsid a gnixif rof tneiciffus si

rLL

kcalb ot detniaper eb dluohs ti neht ,toor eht si ’A‘ fi

Page 104: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 401

rRL

eb dluohs ti neht ,toor eht si ’A‘ fi kcalb ot detniaper

bLL

bRL

.rennam ralimis a ni deldnah era bLR dna ,bRR ,rLR ,rRR epyt fo seicnapercsiD

1 tresni

2 tresni

3 tresni

ycnapercsid bRR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 401

rRL

eb dluohs ti neht ,toor eht si ’A‘ fi kcalb ot detniaper

bLL

bRL

.rennam ralimis a ni deldnah era bLR dna ,bRR ,rLR ,rRR epyt fo seicnapercsiD

1 tresni

2 tresni

3 tresni

ycnapercsid bRR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 401

rRL

eb dluohs ti neht ,toor eht si ’A‘ fi kcalb ot detniaper

bLL

bRL

.rennam ralimis a ni deldnah era bLR dna ,bRR ,rLR ,rRR epyt fo seicnapercsiD

1 tresni

2 tresni

3 tresni

ycnapercsid bRR

Page 105: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 501

4 tresni ycnapercsid rRR

5 tresni

ycnapercsid bRR

snoiteleD

.seert hcraes yranib ni enod si ti yaw eht ,edon a dna ,yek a eteleD der a llits si eert eht ,der si edon deteled eht fI .dlihc eno tsom ta evah lliw deteled eb ot edon A -

.kcalb ot dlihc eht tniaper ,dlihc der a sah edon deteled eht fI .eert kcalb der eht rof sesira ycnapercsid a fI - ht ot gnidrocca eert eht xif ,eert kcalb A .ycnapercsid fo epyt e

.edon kcalb a fo ssol a morf ylno tluser nac ycnapercsid

teL A eht yb denimreted si ycnapercsid fo epyt ehT .seertbus decnalabnu htiw edon tsewol eht etoned( edon deteled eht fo noitacol R ro thgi L ( gnilbis eht fo roloc eht ,)tfe b ro kcal r der fo rebmun eht ,)de

dnarg fo rebmun eht dna dna ,sgnilbis kcalb eht fo esac eht ni nerdlihc - .sgnilbis der fo esac eht ni nerdlihc yam msinahcem noitcerroc eht ,sedon fo noitidda eht morf tluser hcihw seicnapercsid fo esac eht nI

c eht etagaporp eht no deppots dna ,toor eht drawot pu )der detniap dlihc dna tnerap ,.e.i( melborp rolo eht ,sedon fo noiteled eht morf tluser hcihw seicnapercsid fo esac eht ni ,ereH .noitator elgnis a yb yaw

eht drawot etagaporp yam edon kcalb gnissim a fo ycnapercsid na yb yaw eht no deppots dna ,toor .noitator etairporppa na fo noitacilppa

0bR

fo toor eht ot pu ycneicifed eht gnidnes ,roloc fo egnahc

eertbus eht

1bR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 501

4 tresni ycnapercsid rRR

5 tresni

ycnapercsid bRR

snoiteleD

.seert hcraes yranib ni enod si ti yaw eht ,edon a dna ,yek a eteleD der a llits si eert eht ,der si edon deteled eht fI .dlihc eno tsom ta evah lliw deteled eb ot edon A -

.kcalb ot dlihc eht tniaper ,dlihc der a sah edon deteled eht fI .eert kcalb der eht rof sesira ycnapercsid a fI - ht ot gnidrocca eert eht xif ,eert kcalb A .ycnapercsid fo epyt e

.edon kcalb a fo ssol a morf ylno tluser nac ycnapercsid

teL A eht yb denimreted si ycnapercsid fo epyt ehT .seertbus decnalabnu htiw edon tsewol eht etoned( edon deteled eht fo noitacol R ro thgi L ( gnilbis eht fo roloc eht ,)tfe b ro kcal r der fo rebmun eht ,)de

dnarg fo rebmun eht dna dna ,sgnilbis kcalb eht fo esac eht ni nerdlihc - .sgnilbis der fo esac eht ni nerdlihc yam msinahcem noitcerroc eht ,sedon fo noitidda eht morf tluser hcihw seicnapercsid fo esac eht nI

c eht etagaporp eht no deppots dna ,toor eht drawot pu )der detniap dlihc dna tnerap ,.e.i( melborp rolo eht ,sedon fo noiteled eht morf tluser hcihw seicnapercsid fo esac eht ni ,ereH .noitator elgnis a yb yaw

eht drawot etagaporp yam edon kcalb gnissim a fo ycnapercsid na yb yaw eht no deppots dna ,toor .noitator etairporppa na fo noitacilppa

0bR

fo toor eht ot pu ycneicifed eht gnidnes ,roloc fo egnahc

eertbus eht

1bR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 501

4 tresni ycnapercsid rRR

5 tresni

ycnapercsid bRR

snoiteleD

.seert hcraes yranib ni enod si ti yaw eht ,edon a dna ,yek a eteleD der a llits si eert eht ,der si edon deteled eht fI .dlihc eno tsom ta evah lliw deteled eb ot edon A -

.kcalb ot dlihc eht tniaper ,dlihc der a sah edon deteled eht fI .eert kcalb der eht rof sesira ycnapercsid a fI - ht ot gnidrocca eert eht xif ,eert kcalb A .ycnapercsid fo epyt e

.edon kcalb a fo ssol a morf ylno tluser nac ycnapercsid

teL A eht yb denimreted si ycnapercsid fo epyt ehT .seertbus decnalabnu htiw edon tsewol eht etoned( edon deteled eht fo noitacol R ro thgi L ( gnilbis eht fo roloc eht ,)tfe b ro kcal r der fo rebmun eht ,)de

dnarg fo rebmun eht dna dna ,sgnilbis kcalb eht fo esac eht ni nerdlihc - .sgnilbis der fo esac eht ni nerdlihc yam msinahcem noitcerroc eht ,sedon fo noitidda eht morf tluser hcihw seicnapercsid fo esac eht nI

c eht etagaporp eht no deppots dna ,toor eht drawot pu )der detniap dlihc dna tnerap ,.e.i( melborp rolo eht ,sedon fo noiteled eht morf tluser hcihw seicnapercsid fo esac eht ni ,ereH .noitator elgnis a yb yaw

eht drawot etagaporp yam edon kcalb gnissim a fo ycnapercsid na yb yaw eht no deppots dna ,toor .noitator etairporppa na fo noitacilppa

0bR

fo toor eht ot pu ycneicifed eht gnidnes ,roloc fo egnahc

eertbus eht

1bR

Page 106: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 601

2bR

0rR

gnivah dlihc dna tnerap fo ycnapercsid bLL ni tluser thgim

roloc der eht htob

1rR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 601

2bR

0rR

gnivah dlihc dna tnerap fo ycnapercsid bLL ni tluser thgim

roloc der eht htob

1rR

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 601

2bR

0rR

gnivah dlihc dna tnerap fo ycnapercsid bLL ni tluser thgim

roloc der eht htob

1rR

Page 107: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 701

2rR

.2rL dna ,1rL ,0rL ,2bL ,1bL ,0bL ot ylppa snoitamrofsnart ralimiS

seerT yalpS .4.8 : fles( seerT yalpS - :)seert hcraes gnitsujda tsuj seton esehT mottob eht ebircsed - wef a dna ,ammel ssecca eht fo foorp eht ,mhtirogla gniyalps pu

ehT .eert eht fo toor eht ot devom si ti ,eert yalps a ni dessecca si edon a emit yrevE .snoitacilppatnemele eht gnivom tsuJ .)n gol(O si noitarepo eht fo tsoc dezitroma eert eht pu ti gnitator yb toor eht ot

siht seetnaraug taht yaw laiceps yrev a ni enod si tnemevom od seert yalpS .ytreporp siht evah ton seod eseht nI .serutcip fo mrof eht ni selur etirwer eerht gnivig yb mhtirogla eht ebircsed ll'I .dnuob dezitroma

p eht ta gnikool yB .)eert eht fo toor eht ta eb yllautneve lliw taht( dessecca saw taht edon eht si x ,serutci gniwollof eht fo hcihw ediced ew tnerapdnarg s'x dna ,tnerap s'x ,x yb denifed eert eht fo erutcurts lacol

ot eunitnoc eW .wollof ot selur eerht :eert eht fo toor eht ta si x litnu selur eht ylppa

x y >==== / :)esac lanimret( giZ \

y x

z z x / /

giZ - / >==== x >==== y :gaz \ \ z y / y x

x z

/ y \ giZ - / >==== y :giz \ y >====

z x / \ z x

sesac eht lla srevoc hcihw ,tnairav egami rorrim a sah elur hcaE )1( setoN .

giz ehT )2( - .eert eht fo toor eht ot x gnitator tsuj morf gniyalps sehsiugnitsid taht eno eht si elur giz

poT )3( - etis bew ym no si siht gniod rof edoC .ecitcarp ni tneiciffe erom hcum si gniyalps nwod

.)rotaels~/ude.umc.sc.www(

:selpmaxe emos era ereH

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 701

2rR

.2rL dna ,1rL ,0rL ,2bL ,1bL ,0bL ot ylppa snoitamrofsnart ralimiS

seerT yalpS .4.8 : fles( seerT yalpS - :)seert hcraes gnitsujda tsuj seton esehT mottob eht ebircsed - wef a dna ,ammel ssecca eht fo foorp eht ,mhtirogla gniyalps pu

ehT .eert eht fo toor eht ot devom si ti ,eert yalps a ni dessecca si edon a emit yrevE .snoitacilppatnemele eht gnivom tsuJ .)n gol(O si noitarepo eht fo tsoc dezitroma eert eht pu ti gnitator yb toor eht ot

siht seetnaraug taht yaw laiceps yrev a ni enod si tnemevom od seert yalpS .ytreporp siht evah ton seod eseht nI .serutcip fo mrof eht ni selur etirwer eerht gnivig yb mhtirogla eht ebircsed ll'I .dnuob dezitroma

p eht ta gnikool yB .)eert eht fo toor eht ta eb yllautneve lliw taht( dessecca saw taht edon eht si x ,serutci gniwollof eht fo hcihw ediced ew tnerapdnarg s'x dna ,tnerap s'x ,x yb denifed eert eht fo erutcurts lacol

ot eunitnoc eW .wollof ot selur eerht :eert eht fo toor eht ta si x litnu selur eht ylppa

x y >==== / :)esac lanimret( giZ \

y x

z z x / /

giZ - / >==== x >==== y :gaz \ \ z y / y x

x z

/ y \ giZ - / >==== y :giz \ y >====

z x / \ z x

sesac eht lla srevoc hcihw ,tnairav egami rorrim a sah elur hcaE )1( setoN .

giz ehT )2( - .eert eht fo toor eht ot x gnitator tsuj morf gniyalps sehsiugnitsid taht eno eht si elur giz

poT )3( - etis bew ym no si siht gniod rof edoC .ecitcarp ni tneiciffe erom hcum si gniyalps nwod

.)rotaels~/ude.umc.sc.www(

:selpmaxe emos era ereH

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 701

2rR

.2rL dna ,1rL ,0rL ,2bL ,1bL ,0bL ot ylppa snoitamrofsnart ralimiS

seerT yalpS .4.8 : fles( seerT yalpS - :)seert hcraes gnitsujda tsuj seton esehT mottob eht ebircsed - wef a dna ,ammel ssecca eht fo foorp eht ,mhtirogla gniyalps pu

ehT .eert eht fo toor eht ot devom si ti ,eert yalps a ni dessecca si edon a emit yrevE .snoitacilppatnemele eht gnivom tsuJ .)n gol(O si noitarepo eht fo tsoc dezitroma eert eht pu ti gnitator yb toor eht ot

siht seetnaraug taht yaw laiceps yrev a ni enod si tnemevom od seert yalpS .ytreporp siht evah ton seod eseht nI .serutcip fo mrof eht ni selur etirwer eerht gnivig yb mhtirogla eht ebircsed ll'I .dnuob dezitroma

p eht ta gnikool yB .)eert eht fo toor eht ta eb yllautneve lliw taht( dessecca saw taht edon eht si x ,serutci gniwollof eht fo hcihw ediced ew tnerapdnarg s'x dna ,tnerap s'x ,x yb denifed eert eht fo erutcurts lacol

ot eunitnoc eW .wollof ot selur eerht :eert eht fo toor eht ta si x litnu selur eht ylppa

x y >==== / :)esac lanimret( giZ \

y x

z z x / /

giZ - / >==== x >==== y :gaz \ \ z y / y x

x z

/ y \ giZ - / >==== y :giz \ y >====

z x / \ z x

sesac eht lla srevoc hcihw ,tnairav egami rorrim a sah elur hcaE )1( setoN .

giz ehT )2( - .eert eht fo toor eht ot x gnitator tsuj morf gniyalps sehsiugnitsid taht eno eht si elur giz

poT )3( - etis bew ym no si siht gniod rof edoC .ecitcarp ni tneiciffe erom hcum si gniyalps nwod

.)rotaels~/ude.umc.sc.www(

:selpmaxe emos era ereH

Page 108: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 801

3 0 6

/ \ / \ / 5 5 \

/ / \ / \ 5 0 )3(yalps 6 3 )0(yalps 4

/ >======= / \ >======= \ / \ 6 4 1 4 1 3

/ \ \ 2 2 2

/ 1

/ 0

.0 > )x(w thgiew a sah x edon hcae taht gnimussa yb trats ew ,gniyalps fo ecnamrofrep eht ezylana oT

ew sthgiew fo tnemngissa hcae roF .ylirartibra nesohc eb nac sthgiew esehT a evired ot elba eb lliw .dnuob tseb eht sevig taht tnemngissa eht esoohc nac eW .sessecca fo ecneuqes a fo tsoc eht no dnuob

eht no sdnuob rethgit teg ot elba eb lliw ew ,thgiew hgih a stnemele dessecca yltneuqerf eht gnivig yB taht etoN .emit gninnur .lla ta mhtirogla eht egnahc ton od dna ,sisylana eht ni desu ylno era sthgiew eht

).1 eb ot sthgiew eht lla ngissa ot si esac desu ylnommoc A(

x edon a fo ezis ehT .seititnauq erom owt enifed ot deen ew ,ammel ecnamrofrep ruo etats nac ew erofeB

toned( detoned( x edon a fo knar ehT .x ta detoor eertbus eht ni sedon eht lla fo thgiew latot eht si ))x(s de :eseht gnitatseR .x fo ezis eht fo )2_gol(roolf eht si ))x(r

)y(w fo )x ta detoor eertbus eht ni y revo( muS = )x(s

roolf = )x(r )))x(s(gol(

eht eb tsuj lliw noitcnuf laitnetop eht ,ylevitanretlA( .edon taht no snekot )x(r peek ll'ew ,x edon hcae roF

).eert eht ni sedon eht lla fo sknar eht fo smus el eht no sezis htiw delebal ,eert a s'ereH :siht etartsulli ot elpmaxe na s'ereH .thgir eht no sknar dna tf

o 3 o 9 / /

o 3 o 8 / \ / \

1 o o 6 0 o o 2 / \ / \

1 o o 1 3 o o 2 / / / /

1 o o 0 2 o o 1 \ \ 0 o 1 o

:laitnetop siht tuoba setoN

Page 109: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 901

on dna ,y dna x sedon eht fo sknar eht stceffe ylno y dna x sedon fo riap a neewteb noitator a gnioD )1(

r eht erofeb toor eht saw y fi ,eromrehtruF .eert eht ni sedon rehto eht erofeb y fo knar eht neht ,noitato.noitator eht retfa x fo knar eht slauqe noitator

gnol a fo laitnetop eht dna ,)n(O si eert decnalab a fo laitnetop eht ,1 era sthgiew eht lla gnimussA )2(

.)n gol n(O si )eert decnalabnu tsom( niahc

nI )3( .x edon no snekot )x(r gnivah fo kniht nac ew ,sisylana dezitroma fo weiv s'reknab eht

tsom ta si t toor htiw eert a ni x edon gniyalps nehw enod spets gniyalps fo rebmun ehT :ammel sseccA)t(r(3 - .1+))x(r

:foorP

ekot eno yap tsum ew ,krow eht od ew sA erus ekam tsum ew eromrehtruF .od ew pets yalps hcae rof n

)t(r(3 etacolla ot gniog era eW .gnirutcurtser ruo od ew sa x edon no snekot )x(r syawla era ereht taht - .hguone si siht taht wohs ot si foorp eht ni boj ruO .yalps eht od ot snekot 1+ ))x(r

iF sgnilbis owt taht esoppuS .eluR knaR eht dellac ,sknar tuoba noitavresbo gniwollof eht deen ew tsr

ezis eht neht ,r si knar eht fi esuaceb si sihT .1+r tsael ta knar sah tnerap eht nehT .r ,knar emas eht evah ezis evah sgnilbis htob fI .r^2 tsael ta si edulcnoc ew dna )1+r(^2 tsael ta si ezis latot eht neht ,r^2 tsael ta

:margaid gniwollof eht htiw siht tneserper nac eW .1+r tsael ta si knar eht taht

x / \ 1+r => x nehT r r

ew esoppus ,ylsrevnoC rehto eht nehT .r ,knar emas eht evah tnerap sti dna edon a erehw noitautis a dnif

:sknar eseht htiw ,swollof sa derugifnoc sedon eerht evah ew fi oS.r < knar evah tsum edon eht fo gnilbis

r / \ r < x nehT

r x

)x('r(3 eht taht wohs ot si ekat ew hcaorppa ehT .ammel eht gnivorp ot kcab og nac ew woN - ))x(rgiz a eht rof yap ot tneiciffus era snekot - giz a ro gaz - )x('r(3 taht dnA .spets giz - ot tneiciffus si 1+ ))x(r

r ereH( .pets giz eht rof yap knar eht stneserper )(r dna ,pets eht retfa noitcnuf knar eht stneserper )(' ).pets eht erofeb noitcnuf

:ot epocselet yeht ,noitarepo yalps eritne eht rof tsoc dezitroma eht etupmoc ot stsoc eseht mus ew nehW

)t(r(3 - .1+ ))x(r

ht taht etoN .ecno ylno neppah nac hcihw ,pets giz eht morf semoc 1+ e

:sknar era slebal eht ,elpmaxe na s'ereH

x 2 o 2

Page 110: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 011

/ / \ 2 o o 0 o 2 / /

o 2 )x(yalps o 2 / >========== / \

0 o o 1 x 2 / \ /

o 0 1 o o 0 /

0 o

----------------- ---------------- 7 9 :latoT

2(3 :detacolla eW - 1 = 1+)2

9 :gnirutcurtser morf snekot artxe - 2 = 7 ------

3 ts yalps 2 era erehT .hguone evah ew dna ,2 > 3 oS .spe

sepyt eht fo hcae rof eno ,sesac eerht era erehT .spets laudividni eht rof sdnuob eseht wohs ot sniamer tI

.spets yalps fo

:giZ r o o r >== / \

o a r =< b o

htiw meht tnemgua dna a no snekot eht ekat eW .siht no nekot eno dneps ew os ,1 si tsoc lautca ehTr rehtona - r+1 si dedeen snekot fo rebmun latot eht suhT .b no meht tup dna a - r(3+1 tsom ta si sihT .a - .)a

giZ - ps ll'eW :gaz :sesac 2 otni ti til

.pets eht fo edon gnidne dna edon gnitrats eht neewteb esaercni ton seod knar ehT :1 esaC

r o o r / / \

b o o a >=== o r \

o r siht esu ew .erutcurts atad eht morf desaeler si nekot eno os ,r < eb tsum b ro a fo eno ,eluR knaR eht yB

.krow eht rof yap ot r(3 fo noitacolla ruo ,suhT - .siht rof yap ot tneiciffus si 0 = )r

seod knar ehT( :2esaC )esaercni

r o o r

Page 111: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 111

/ / \ d o o c >=== o b

\ o a

suac ereht hguone era erehT( .b no esoht morf deilppus eb nac c no snekot ehT ).c => b e

r taht etoN - :oS .0 > a

r esu - krow eht rof yap ot )1 tsael ta si hcihw( a r esu - d rof hguone ekam ot a no snekot eht tnemgua ot a

r(2 :sevig owt eseht gnimmuS - r(2 tuB .)a - r(3 =< )a - giz eht setelpmoc hcihw ,)a - .esac gaz

giZ - giz .sesac owt otni tilps ew ,niagA :

eht dna edon gnitrats eht neewteb esaercni ton seod knar ehT :1 esaC

.pets eht fo edon gnidne

r o o r o r / / \ \

o r r =< c o >==== d o o r >===== / \

r < d o )elur knar yb r<d( o r giz eht ni sA - < d esuaceb deniag nekot eht esu ew ,esac gaz evah ew suhT .pets eht rof yap ot r

r(3 - .0 deen ew dna snekot 0=)r .pets eht gnirud sesaercni knar ehT :2 esaC

r o o r / \

>============ o b r =< c o / \

r =< d o o a r esu - krow eht rof yap ot )1 tsael ta si hcihw( a r esu - d rof dedeen esoht revoc ot a no snekot eht tsoob ot a r esu - soob ot a c rof dedeen esoht revoc ot b no snekot eht t

r(3 sevig eseht gnimmuS - giz eht fo sizylana eht setelpmoc hcihw ,)a - .esac giz

eht setelpmoc sihT .ammel ssecca eht fo foorp emit sekat sedon n fo eert a ni syalps m fo ecneuqes A :meroehT ecnalaB gol m(O n + )n(

.))n(gol

roF .1 ot lauqe sthgiew eht lla htiw ammel ssecca eht ylppa eW :foorP =< )t(r ,yalps nevig afo tsoc dezitroma eht oS .0 => )x(r dna ,)n(gol :tsom ta si yalps eht

Page 112: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 211

1 + )n(gol 3

slaitnetop fo dlrow eht ot gnihctiws won eW ni snekot latot = laitnetop( fo tsoc eht dnuob oT .)eert ehtrof tnuoma siht dda ew ecneuqes eht laitini ehT .laitnetop lanif eht sunim laitini eht dda neht ,yalps hcae

.0 tsael ta si laitnetop lanif eht dna ,)n(gol n tsom ta si laitnetop ob a sevig sihT :fo dnu

))n(gol n + )n(gol m(O = )n(gol n + )1 + )n(gol 3( m gniyalpS

x ta pets yalpS

x edon fo tnerap = )x(p tel

1 esac eert eht fo toor = )x(p )giz(

2 esac giz( - nerdlihc )thgir( tfel htob era )x(p dna x dna toor eht ton si )x(p )giz

3 esac giz( - dlihc ) tfel(thgir a si )x(p dna dlihc )thgir( tfel a si x dna toor eht ton si )x(p )gaz

toor eht si ti litnu X no pets yalps eht taeper ,X edon a yalpS oT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 211

1 + )n(gol 3

slaitnetop fo dlrow eht ot gnihctiws won eW ni snekot latot = laitnetop( fo tsoc eht dnuob oT .)eert ehtrof tnuoma siht dda ew ecneuqes eht laitini ehT .laitnetop lanif eht sunim laitini eht dda neht ,yalps hcae

.0 tsael ta si laitnetop lanif eht dna ,)n(gol n tsom ta si laitnetop ob a sevig sihT :fo dnu

))n(gol n + )n(gol m(O = )n(gol n + )1 + )n(gol 3( m gniyalpS

x ta pets yalpS

x edon fo tnerap = )x(p tel

1 esac eert eht fo toor = )x(p )giz(

2 esac giz( - nerdlihc )thgir( tfel htob era )x(p dna x dna toor eht ton si )x(p )giz

3 esac giz( - dlihc ) tfel(thgir a si )x(p dna dlihc )thgir( tfel a si x dna toor eht ton si )x(p )gaz

toor eht si ti litnu X no pets yalps eht taeper ,X edon a yalpS oT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 211

1 + )n(gol 3

slaitnetop fo dlrow eht ot gnihctiws won eW ni snekot latot = laitnetop( fo tsoc eht dnuob oT .)eert ehtrof tnuoma siht dda ew ecneuqes eht laitini ehT .laitnetop lanif eht sunim laitini eht dda neht ,yalps hcae

.0 tsael ta si laitnetop lanif eht dna ,)n(gol n tsom ta si laitnetop ob a sevig sihT :fo dnu

))n(gol n + )n(gol m(O = )n(gol n + )1 + )n(gol 3( m gniyalpS

x ta pets yalpS

x edon fo tnerap = )x(p tel

1 esac eert eht fo toor = )x(p )giz(

2 esac giz( - nerdlihc )thgir( tfel htob era )x(p dna x dna toor eht ton si )x(p )giz

3 esac giz( - dlihc ) tfel(thgir a si )x(p dna dlihc )thgir( tfel a si x dna toor eht ton si )x(p )gaz

toor eht si ti litnu X no pets yalps eht taeper ,X edon a yalpS oT

Page 113: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 311

B yalpS

evoM .sv yalpS - ot - toor

1 esaC

2 esaC

evoM .sv yalpS - ot - toor

3 esaC

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 311

B yalpS

evoM .sv yalpS - ot - toor

1 esaC

2 esaC

evoM .sv yalpS - ot - toor

3 esaC

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 311

B yalpS

evoM .sv yalpS - ot - toor

1 esaC

2 esaC

evoM .sv yalpS - ot - toor

3 esaC

Page 114: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 411

evoM - ot - A toor

A yalpS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 411

evoM - ot - A toor

A yalpS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 411

evoM - ot - A toor

A yalpS

Page 115: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 511

eerT yalpS fo ecnamrofreP

emit )d(atehT sekat d htped fo edon a ta gniyalpS

k noitarepo fo tsoc lautca =kc

k noitarepo fo tsoc dezitroma =

kD ot noitarepo ht'k gniylppa retfa erutcurts atad eht fo etats eht = kD

p = kD htiw detaicossa laitneto

:teg ew os

:yb nevig si deriuqer krow fo tnuoma lautca ehT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 511

eerT yalpS fo ecnamrofreP

emit )d(atehT sekat d htped fo edon a ta gniyalpS

k noitarepo fo tsoc lautca =kc

k noitarepo fo tsoc dezitroma =

kD ot noitarepo ht'k gniylppa retfa erutcurts atad eht fo etats eht = kD

p = kD htiw detaicossa laitneto

:teg ew os

:yb nevig si deriuqer krow fo tnuoma lautca ehT

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 511

eerT yalpS fo ecnamrofreP

emit )d(atehT sekat d htped fo edon a ta gniyalpS

k noitarepo fo tsoc lautca =kc

k noitarepo fo tsoc dezitroma =

kD ot noitarepo ht'k gniylppa retfa erutcurts atad eht fo etats eht = kD

p = kD htiw detaicossa laitneto

:teg ew os

:yb nevig si deriuqer krow fo tnuoma lautca ehT

Page 116: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 611

laitnetop ni ecnereffid dna krow dezitroma latot eht deen oS

seerT yalpS rof laitnetoP

:teL

eulav yrartibra tub dexif a ,x edon fo thgiew = )x(w

= )x(ezis

))x(ezis(gl = )x(knar

elpmaxE

eert eht ni sedon fo rebmun eht si n erehw n/1 = )x(w teL

ammeL )t(r(3 tsom ta si t ta toor htiw eert a ni x edon yalps ot emit dezitroma ehT - = 1 + ))x(r

)))x(s/)t(s(gl(O

eb snoitcnuf knar ,ezis eht etoned r ,s teL yalps a erof

yalps a retfa snoitcnuf knar ,ezis eht etoned 'r ,'s teL

snoitator tnuoC

1 esaC noitator enO )giz(

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 611

laitnetop ni ecnereffid dna krow dezitroma latot eht deen oS

seerT yalpS rof laitnetoP

:teL

eulav yrartibra tub dexif a ,x edon fo thgiew = )x(w

= )x(ezis

))x(ezis(gl = )x(knar

elpmaxE

eert eht ni sedon fo rebmun eht si n erehw n/1 = )x(w teL

ammeL )t(r(3 tsom ta si t ta toor htiw eert a ni x edon yalps ot emit dezitroma ehT - = 1 + ))x(r

)))x(s/)t(s(gl(O

eb snoitcnuf knar ,ezis eht etoned r ,s teL yalps a erof

yalps a retfa snoitcnuf knar ,ezis eht etoned 'r ,'s teL

snoitator tnuoC

1 esaC noitator enO )giz(

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 611

laitnetop ni ecnereffid dna krow dezitroma latot eht deen oS

seerT yalpS rof laitnetoP

:teL

eulav yrartibra tub dexif a ,x edon fo thgiew = )x(w

= )x(ezis

))x(ezis(gl = )x(knar

elpmaxE

eert eht ni sedon fo rebmun eht si n erehw n/1 = )x(w teL

ammeL )t(r(3 tsom ta si t ta toor htiw eert a ni x edon yalps ot emit dezitroma ehT - = 1 + ))x(r

)))x(s/)t(s(gl(O

eb snoitcnuf knar ,ezis eht etoned r ,s teL yalps a erof

yalps a retfa snoitcnuf knar ,ezis eht etoned 'r ,'s teL

snoitator tnuoC

1 esaC noitator enO )giz(

Page 117: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 711

:si pets siht fo emit dezitromA

])y('r + )x('r[ + 1 - )x(r - knar egnahc y dna x ylno )y(r

)x('r + 1 =< - )x(r

)y('r => )y(r

< )x('r(3 + 1 = - ))x(r

)x(r => )x('r

2 esaC giz( - snoitator owT )giz

:si pets siht fo emit dezitromA

)z('r + )y('r + )x('r + 2 - )x(r - )y(r - knar egnahc z, y ,x ylno )z(r

)z('r + )y('r + 2 = - )x(r - )y(r

)z(r = )x('r

)z('r + )x('r + 2 =< - )x(r2

r dna )y('r => )x('

)x(r => )y(r

)x('r2 taht emussA - )x(r - 2 => )z('r

)z('r + )x('r + 2 - )x(r2

)x('r2 =< - )x(r - )z('r + )x('r + )z('r - )x(r2

)x('r3 = - )x(r3

)x('r2 wohs ot deeN - )x(r - 2 => )z('r

1 mialC

1 = b teS - a

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 711

:si pets siht fo emit dezitromA

])y('r + )x('r[ + 1 - )x(r - knar egnahc y dna x ylno )y(r

)x('r + 1 =< - )x(r

)y('r => )y(r

< )x('r(3 + 1 = - ))x(r

)x(r => )x('r

2 esaC giz( - snoitator owT )giz

:si pets siht fo emit dezitromA

)z('r + )y('r + )x('r + 2 - )x(r - )y(r - knar egnahc z, y ,x ylno )z(r

)z('r + )y('r + 2 = - )x(r - )y(r

)z(r = )x('r

)z('r + )x('r + 2 =< - )x(r2

r dna )y('r => )x('

)x(r => )y(r

)x('r2 taht emussA - )x(r - 2 => )z('r

)z('r + )x('r + 2 - )x(r2

)x('r2 =< - )x(r - )z('r + )x('r + )z('r - )x(r2

)x('r3 = - )x(r3

)x('r2 wohs ot deeN - )x(r - 2 => )z('r

1 mialC

1 = b teS - a

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 711

:si pets siht fo emit dezitromA

])y('r + )x('r[ + 1 - )x(r - knar egnahc y dna x ylno )y(r

)x('r + 1 =< - )x(r

)y('r => )y(r

< )x('r(3 + 1 = - ))x(r

)x(r => )x('r

2 esaC giz( - snoitator owT )giz

:si pets siht fo emit dezitromA

)z('r + )y('r + )x('r + 2 - )x(r - )y(r - knar egnahc z, y ,x ylno )z(r

)z('r + )y('r + 2 = - )x(r - )y(r

)z(r = )x('r

)z('r + )x('r + 2 =< - )x(r2

r dna )y('r => )x('

)x(r => )y(r

)x('r2 taht emussA - )x(r - 2 => )z('r

)z('r + )x('r + 2 - )x(r2

)x('r2 =< - )x(r - )z('r + )x('r + )z('r - )x(r2

)x('r3 = - )x(r3

)x('r2 wohs ot deeN - )x(r - 2 => )z('r

1 mialC

1 = b teS - a

Page 118: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 811

evah eW

teg ew eulav emertxe dnif ot 0 ot siht gnitteS

os

2/1 = b dna 2/1 = a si taht

=)2/1(gl+)2/1(gl tub -2

1 mialc dnE

2 mialC )x('r2 - )x(r - 2 => )z('r

:taht llaceR

:evah eW

)z('r + )x(r - ))z('s(gl + ))x(s(gl = )x('r2 - ))x('s(gl2

x('s/)x(s(gl = ))x('s/)z('s(gl + ))

)x('s =< )z('s + )x(s woN

)?yhW(

os

1 =< )x('s/)z('s + )x('s/)x(s =<0

teg ot 1 mialc ni b= )x('s/)z('s dna a = )x('s/)x(s teS

=< ))x('s/)z('s(gl + ))x('s/)x(s(gl - 2

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 811

evah eW

teg ew eulav emertxe dnif ot 0 ot siht gnitteS

os

2/1 = b dna 2/1 = a si taht

=)2/1(gl+)2/1(gl tub -2

1 mialc dnE

2 mialC )x('r2 - )x(r - 2 => )z('r

:taht llaceR

:evah eW

)z('r + )x(r - ))z('s(gl + ))x(s(gl = )x('r2 - ))x('s(gl2

x('s/)x(s(gl = ))x('s/)z('s(gl + ))

)x('s =< )z('s + )x(s woN

)?yhW(

os

1 =< )x('s/)z('s + )x('s/)x(s =<0

teg ot 1 mialc ni b= )x('s/)z('s dna a = )x('s/)x(s teS

=< ))x('s/)z('s(gl + ))x('s/)x(s(gl - 2

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 811

evah eW

teg ew eulav emertxe dnif ot 0 ot siht gnitteS

os

2/1 = b dna 2/1 = a si taht

=)2/1(gl+)2/1(gl tub -2

1 mialc dnE

2 mialC )x('r2 - )x(r - 2 => )z('r

:taht llaceR

:evah eW

)z('r + )x(r - ))z('s(gl + ))x(s(gl = )x('r2 - ))x('s(gl2

x('s/)x(s(gl = ))x('s/)z('s(gl + ))

)x('s =< )z('s + )x(s woN

)?yhW(

os

1 =< )x('s/)z('s + )x('s/)x(s =<0

teg ot 1 mialc ni b= )x('s/)z('s dna a = )x('s/)x(s teS

=< ))x('s/)z('s(gl + ))x('s/)x(s(gl - 2

Page 119: DATA STRUCTERS WI TH C 10CS3 5 DATA STRUCTURES WITH C Total Hours : 52 Exa m M a rks ... · 2013-10-24 · DATA STRUCTERS WI TH C 10CS3 5 DEPT OF C SE, SJBI T Page 4 UNIT – 1: BAS

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 911

)z('r + )x(r suhT - =< )x('r2 - )x('r2 ro 2 - )x(r - 2 => )z('r

C 3 esa giz( - )gaz

.5.8 SNOITSEUQ DEDNEMMOCER .eerT LVA enifeD .1

?snoitator LVA fo seirogetac eht era tahW .2

eert LVA ni edon a fo rotcaf ecnalab yb naem uoy od tahW .3

.eert yalps enifeD .4

?gniyalps dniheb aedi eht si tahW .5

fo sepyt eht tsiL .6 .eert yalpS ni elbaliava snoitator

?h thgieh fo eert LVA na ni sedon fo rebmun muminim eht si tahW .7

.eert hcraes yranib lamitpo si tahW .8

deR a fo noitatneserper eht nialpxE .9 - .eert kcalb

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 911

)z('r + )x(r suhT - =< )x('r2 - )x('r2 ro 2 - )x(r - 2 => )z('r

C 3 esa giz( - )gaz

.5.8 SNOITSEUQ DEDNEMMOCER .eerT LVA enifeD .1

?snoitator LVA fo seirogetac eht era tahW .2

eert LVA ni edon a fo rotcaf ecnalab yb naem uoy od tahW .3

.eert yalps enifeD .4

?gniyalps dniheb aedi eht si tahW .5

fo sepyt eht tsiL .6 .eert yalpS ni elbaliava snoitator

?h thgieh fo eert LVA na ni sedon fo rebmun muminim eht si tahW .7

.eert hcraes yranib lamitpo si tahW .8

deR a fo noitatneserper eht nialpxE .9 - .eert kcalb

C HTIW SRETCURTS ATAD 53SC01

C FO TPED TIBJS ,ES egaP 911

)z('r + )x(r suhT - =< )x('r2 - )x('r2 ro 2 - )x(r - 2 => )z('r

C 3 esa giz( - )gaz

.5.8 SNOITSEUQ DEDNEMMOCER .eerT LVA enifeD .1

?snoitator LVA fo seirogetac eht era tahW .2

eert LVA ni edon a fo rotcaf ecnalab yb naem uoy od tahW .3

.eert yalps enifeD .4

?gniyalps dniheb aedi eht si tahW .5

fo sepyt eht tsiL .6 .eert yalpS ni elbaliava snoitator

?h thgieh fo eert LVA na ni sedon fo rebmun muminim eht si tahW .7

.eert hcraes yranib lamitpo si tahW .8

deR a fo noitatneserper eht nialpxE .9 - .eert kcalb