0% found this document useful (0 votes)
57 views27 pages

CS Practical - Compressed

List of

Uploaded by

Jacob Davies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
57 views27 pages

CS Practical - Compressed

List of

Uploaded by

Jacob Davies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 27
Et a s Grete 4 eqzam to iAsest | Atm : | Aasde ‘inte linked trot» Algowithm —> Peocedae Mode (NODE) _ (node ‘is_not fednd_) | @ Te (Avare = Nol) “Pint “The _memosy bank does oot | contdin any __Feee nedes '! zetuen (Nuit) else [Feee nodes ave availble 19 +he _memovy bank se aie zeach_a node oF sequined sized @ PrR = AVATL ——> LINK @_[&easching a node of vequised seize To the tinked Mat] Size in the _ifnked Uist J cinile (( Srzeor (PTR) + suzeor (NODE)) and (PTR = Nutt ))) EGR Eke PTR = PTR S EINK. end while [Free _nede of given size ts found J . Teacher's Signature... rnorne = =a @ ee (orzcor (PTR) = See (ove) a pred —> bENK = ee cee LES rebusn (PTR Else [Point “| Could not fiédl atiock of the 6 zequived_ size rvetusn (NULL) End TF Eod if |S Stor i Description s-=tf a feee node of aequived size To avdibable 10 the memory bank then =the. it | ‘ingestion 1s posible orheswise q@ _oode connect _be Sobes ted - _ Trig peoceduee bo find 4d Foee node of ‘table size feom =the _memorr bank | = see Thote ll succese fully itn | ptndingll' dl inoue | of euitable size than Tt well make —the ned poinkes= point it dleo fow it well petuam ALL - have studied i Result $- ~Thus ) we Hew to insert rode Inte aq _finked list « Gitte 9 peoqnacn to_create. Insest + aa Sxcular linked lot - elete a node in 6 a || Theo Oe Tr Ie oy Rigestthm Pacem TLN serT— 6t— AN areT KEY ees = Set | @ re Cred o/Nutt) then __Peink neuFfrctent memory ¢ AQede _cannect __||_ be ‘insested Exist @_ Else r _|| pre = HeapeR, ——> EENic Gihile_C(( PTR ——> DATA = KEY) and (eTR— crnk - Nutr )) do Pri pape EEN end while . (pre —> utwe = uct) then —— EW — > EEK a LTR LiKe = NEG _oew ——> Dem = x PTR. —> LINK @) Else || __Poink “key nok found ‘Teacher's Signature . a - oe Deere sulky (ists KEY) ~ Cist ts empty] a [Oe (HeAbeR > tone = Mutt) then I} paint “the list 16 empty 2 Deletion Net possible “ Exit || ena ie yy | Crnittaitze the poimtes- pret and pre J @ Pre = HeADER 2 PTR = PIRI => WINK CSeaxch For the location of key J rt |@_Gihite (PTR + Now) do HSE Crr— Dara = key) -then PTR 1 = PTR key 46 found ct face mode | a ee eerie Shui) le ee [rreoe Ware shen aod ete RT pret -——> LINK = NOLL Retuen — node ELe = Rib. ea ble __||}@ Else A Ckey 14 found sémeahese io the middle J te 2A |@ ptr | —> ttn = Pre — > EENK Retusn— node (PTR) [exit [| end iF end if end while [key mot found ] “EF (PTR=NuL) then Paint" nede eith the key does mot exist | _Peletion mot posible " end iF + @_&top - Dp escviptio ns A__civculae linked fist is q | sing ule fined Te Which =the list ede 4 peinting at the fivek ‘Teacher's Signature , || ede to stread of Mute. — IF foee node of weguised ize 18 “available the memory” tank then _ooly _ ts possible st fet Ys empty _ then fot _poseible 5 [Re suH-_& pl = = I _) Saints ae have Studied i How-to caeate insert .« delete q node in ciscutas~ linked list | = aang | Practrcar No.3 ae ’ Penctzcar No.3 _ a eee aon es _Chatte uah a Cite 9 Peeps — ee element ‘inte __ Fs _4. cere ars ssi inked fist “PUSH = LINK stack (Corack £ThM) LE THODE (NODE) |@ IEF (neq| = Nuk =) then pink \ Memory is insufficient & Not be Fnsexked ovarflew, occused 3 Mew Nede ox « exit |@_ Else — J neal —» Dara = CTEM || iW] meej —> LENK = “ToP uw) Top = New | iw] Headex— Stack — LINK = Top le End Ff @_ext . 0 eR ge L ’ Algovi-thn SS ee) ee Be ee are ee ss, papa Tk osha era. © _ =F Tee = Nutt print “ stack ts empty § UnderPlow accused mu o : Nk = PTR. w]_Rekiren (oun): @_end TF @) Htop 3 Push () $ =t Ynsexts an elements +o_-the op of the stack + — Tt jo -+takes Ol) Hime, as each node jo ‘Tnspsted at -the level top of linked Met + Pop () 8 = zemove aq_elements fam he to ab the Stack: — + takes 01) Hime » a6 —the stop always push Stack GANOHI — xa no and pop of implement pe “newt iincerted node points _-fo —the Ue tudied _taw —to , Studied _ tat = stement ‘into Faom _a asi Ninked list + ng _ oe GANDHI | Aim, - Giile_a paoquam -po solve _-toces” of i = A a > ry &g i _____ Hani foe using wecyssion + af @_cfile Bega —> END _ Renee _fend of the Stouctuee ] Ia beers ofa dtsks 5 = From pen AUX to call —y8eieR CI 1AOK ) BE@ + END) E j Le eae : GANDHI AGEN 2 _Discxiption = ? : : Tatieo- of (uqnol = (ord ma thematical sia | puzzle ashich__coneists SF thee ||_ owes (pegs) _and main —the one + Tl Sines 2ings A _diffewent sizes and | qthached upon 640 as cending i odes - — “These ave other coovtations of ~the uzzle ewhese —-the numbes of disks jnevese but +he —fowes count zemain -the Same . |— “The gules that should be followed chile Solving the problem ave , f!, Only one -+op most dist can be moved at a time . J|__2. Ghile placing the disk on peq 1 smallex disk ——> LINK PTR = FRONT enmile (pTR.—> tEnk Ae HuL) do PTR = PTR — GENK eod_ aihile 4 ea —> DATA =—TeM prR — LINK = NEW NEW ——> CEHK = NOLL REAR_ = NEG | Aiqostthm == 7 : ray pean + Xen) D pre = Headew >» Link sie e @® tC tink Queve te empty 1 ( pre =Hpet | _ | ee TR = Hypct oe “Deletion 92 4 prok “te Pueue ws _emphy posmrble nt end tf Chee ie only one nade in the pueue ) (émerty —> CINK =Nui) | _ |e ss (pre + net) aod —> DATA Te = FRONT Header ——> LENK = Nuc Readesr— node (FRONT \ A) else |e) [ Queue neo a Sumber of nodes J pre 4 sf RONT — pINk “Ete =. FRONT -—> DATR Weades- ——> LEENK = Pree Rétuan ——> ten = PTR 1 ce (Cy (@) top: Disexcption 2— @ A queue. 45 aq lined dated IL wotouckhive om _ Orr Yabotoact datd stauctuse I having oadesd Blements_ of similae data pean eath ‘insertion fakes place oF the aca “end @ The queue and deletion +tcikeo place at the front end of the queue queue Jo a froear cata _stouctuoe wth some vestatctions imposed on _tk- Gy ~The aestaictiong axe ineertfon —takes place et one end and deletion takes place at —the _othes-__end - @ fi queue ts an ordered {fst of aurni la data element + @ “The end at which elements are __inseated called REPR. Tq called ONT 19 (Fro) _tigt fest out That %& element _wmch entess 4 uegque Cook ee in ehich tt leaves the q weue , << ew GANDHI) PAGE No: (15, ueUe go oo oS @ ~The element “thet: Fe aantting: 1A the ¢ SJ enh oe one that 19 fox the longest -ifme te the = S) deteted Geto @) —The New element _aleoays 9199 the _queuce at +he end (@_clo_elemenk can be~ enteed ‘into ow clele ted foom —the middle” of the queue - (2) “The _lnses}ton _aldootthm sill Insert a nede In the quecde at the REAR end » (@) Sot ts asumed that a CRaetie te 49 the fowm -f single finked tot and 15 citweady pocsenk Sta fhe memooy + Ceoult 38> “Thus we have studied how +o pesfoom t to Yasestion and cletetion ind _quewe in Static _Sa- Teyplementation : dele tie) ee J opevation of _crowulaas Algeaithm 3 Le cweretT) (Pueve 1 FRonm 7 FEAR: eM _S6rZeG) XP (front per +1) then, paok Queve jo fall © —ihe | exit f eloe Quer ive ‘iis Em phy a uF pean =o) aod (PRONT so) then 2 FRONT = REAR. =1 Elce, [E@Pueue how some elements | & KP CREAR = SEzeoF and Front =e 1) REAR =| Fibe REAR = REPR Tt] end if — CQUEVE (Ream) = 1TEM End “Ff tnd iF Teacher's Signature ... GANDHI PAGE No. = mo of Practical sp. Step: oe = CQeelL ere mCOORe See eonn eens Teer) Sree. De 1. ote ChRSNt =o) nem paint wcpueue~ is SOY 0 Else e j [Lease 2 3 ueue has single element Si zg. TTtm = Qveve = REARS FRonT =o RERR =o Eise [cage 3% Dueue has some elements J an ae FRONT = 4ize q_ EFRont =1 else FRoNT = FRONT +1 4 end Tf =. end a 6. Rrop Teacher's Signature... PAGE ND @ Disestption 8— Oe queve a Full hows the altaned 4a Maximum size the Stashin' location oP the quere are. emnphy and hence Sas of memory @__f_dovrma _quewe can Fneest elements until = } queue becomes full Z @ A cCiacutay queue like zing and stat fi ra 7 } Practical fhe quewe The Fuctt (5) “The pointess FRONT ond REAR move TA clockwise dizec tion allen -the location as queue i cisculaa e Cteculay quewe fo q jineaa dala _stuuctuee jamemenete operations ave performed on Pxot IN Flash ouk painciple Crirro) and the last _pogition ie coMnected back to the féost position do make a civele - @ the ingestion ON aireuilad queue atqovithm _iAsexk on element Em inbo Vie CrRCULLAR Qurut c8 Size SGIrZEQ , ve & FRONT poin 5 points +e the Eeont ead And REAR. _poinkes= points +o she zreqa end Sieha 3 CQUEVE . ni Teacher's Signature ..... in +he PUEVE - A mM. deleton 159 ciaculao gene aigosrthm _cleletes on element fxm 5 5 fhe QUE VE of size sizeD oo (@) FRONT oinkes points +o__+the a } Desukii Sis hey mere Pune Steudted in perform —_iaseation ‘cind deletion operitipn ON cloculas Jue le tal LE ob my t a fae GANDH! po tn: (73), $ ae) ot oF) cipdcy Prrerrent “9: } | | athe PJgori thm ‘ je J reestion aor lk (AUN) 1 A cod =o ae og. 1=2N pti] 16 ascumed to be santed Se j compapision staste from _Gecond _elemen? of _avaay + t 2 cinile Cig) do ' femp = A i) eee i-\ th Fe mle (temp 2 A imend y 7 = i) pterR Hy = afetri a) PTR = PTR-I iL 4) end adnile . a [eTR +1) emp Santee 4+ epk while =r are an PAGE No.2) h peciption 2 O peoaeechonmecsr Be cere We similar to. the aovting _algoaithon that works a ee a tqnde ia fou™ hhands- QB) —The _a50ay is TaBes Gt an imo 4 ‘| gooted and an ungosted poor * (a_Nalues from Awe uneosled past ave picked in the and placed ab the conaeck position coated Gol - @®_—The seated pask contains —anly _—the _fiost “element 2p the lieth 1 while +hé Ws ob the list is in the uneosted list + () “the ajgoa thy then _theaates +hoough each erements ig he unsoated aah picking one ak ad Hme and insests ib into its conoect position in the souted pact - @) ~The algoaitin compdses the cusme nt = Jo Lil element with each element tr the Soaked past 1 Stavting foom the yqht - most Element S d 4 Result 3— —Titis 1 we pave studied + bo sost an sans) sing insestiorn soo} - e”™”-—( Wlhthtt~C~ GANDHI proena. (22) no ond ee ees Cite _q_pooguarn te ingest AN pine es - seach faee and Foavesoe hein) poset of Practical (ome Plgostihm o= pesdverea Tenfo: Lert » Right S poor] 1 Sep oh) Se STAC eS wens and pir > ROOT) Taenikaly push HO Into stack and PTR pofiter te the set voot node of treed D+ Repeat steps | io S while PTR =p qUeL Shei he Saas ago CPT] ay. {Handing eight child J aes = CET RIGHT CePTR) = HULL +hen Cevsy night node onto srack | ie ie pao eee) is Steck Esor] = great? Cerri end ih + s+ Grand ing’ teth child J ae t Ty lett frre ) +e Mult then et Pie leee Gane | elso (Por foom oe A See ee | EOC )h3$/U — 3Sti—

You might also like