0% found this document useful (0 votes)
20 views9 pages

Python Assignment 2

Uploaded by

Indrajeet Sharma
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)
20 views9 pages

Python Assignment 2

Uploaded by

Indrajeet Sharma
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/ 9
QhulImeplnrcuiat Quwul Bats Implumutivg gut val way # in + yin: Codi? i e Clas quiet > | ap init. (self, sigtetoo)? selp-q = [Non] * Sixt Y : oe self. capacity = ° sey. front = 0 Setf. yeah =~ sett. count = 0 ay digurur (eelp): 1 eelpoihemply print (! unt Ondurflor') MPSBEOE UM tabs trie vad x= seth. q [sey front] prtnt (' Rumoving elumunt...” oO) : sel front = (self: frent +1) ¢/. oat self. counk = sett. wunt -] : rib x ; ‘ Ot enquire (self, valu) : TE eel}. toPut (): Paint (‘Overflord)* exit (-1) ot ) PAINE ( dnteating elunut sh rear = (self veare sdf 4 [redt. rear] sdf -ount = selt-cbunt AL display (oof) if self isémpty O° Paint (Tree quit is OmMP exit (1) Abu, colt. q [eel prove] ty’) at size (self): ruturn setf-count prink (Ts quiwe size at, 983) paint (1 Tu front elument 14’ q-diplay 0) FY daguere () Paint (TW pout elise uur, q-aiplay O) 4: daguiu () ‘ qdagquunt () soidiap tay.’ Output: Tnierting eum... | Interking eliment...2 Imouhng elumeut-- 3 Te quurt sizt Mh 3 The front elument iA |” Removing element | The brent elumint 1A 2 Removing element 2 Fie Removing clenant 3 Thr quiut th empty Qouwrdopununt dub And = Implinenting alist fm payed © Cods * ilist = (10,20, 30,40, Co ,66,10,801490, 100} paint Cluck: |) ilict ) paint ("Fivck elumint * + vlisetol) 3e res print (vRountk cununt 7, Lise 13d) print (ust clement fron 0 bo 4 index : PAInt (' 3rd or = 7h ; "ise 7) TList. append (111) : i: Sem : Print (’ List otter append O:'. (list) ag paint (inde ef \Bo\': |, iLisk. indsx (80) print Uofty pop Ls", list pops) foe tat - renove [o) Paint (‘apts munroving Bo: flit -imsert (2,100) FoRee ~ print (aftr fs ent: > CLUE NE om prink (‘numba 9 Decent o| Rion flat. extend CLI -22,333) ‘ 5 . é ees paint ("opty extending: ilist) : a Bey ig ilist- reverse U) “ogee prt (aptr rversinag 2" Llck i Oukput + ~ List : [10,20,30,40, or /60,10, 80,9 first elunwd = lo Founth elsmudt > 40 Uist elemunts from © to 4 fh Srd oy -Tin elinunt + 4o a fbr append )! [10,20 130,40, £0, 60/70, 6090, nda ag OFLU sorting: [10,20,30,40,60” Popped + [10,20 80,40, 0760/10/89) 90/108) 1 ,30,40,6 0 6070, 49/100 070,90, 90/1007 11) After vermoving’ Go!» [10,2 aftr iret. [ro,20, igo, 30) 40/00, 69-7019 00 ,cee 4 nuniber I Occunancu of hae 30,40, 00, Jo, 60,60 740,301 00) aft exlencling : [10,20, 100 60,70, GO, 100,123 Yt Aeversing : [3,22 W1V,100,904 Quts-3 Tarplnunt : i A= Impinuntyg arrout fn py ton: Coda: Tncpont OANGY Gt OA a-anm.onay('i', LI), 2,37) print ("Array before inseation | ") por tin ri (0,3): ‘ ij paint (aliJ, end" ") : peink () a-imet (1,4) paind (Array oft insertou: “) for i in (09. 7 prink (tL, end") print 0) print (First elununt fA- Usoalion) paint (1 Te popped elumunt iA : end ="") print (edva: pop?) Paint (" Tt aray cf ty Popping ws Veen Jor i in yeunge (0,4): Paint [ati], end" ") Paint Une") b = an-anay ('0’, L1,2, 314i roy Tay paint ("Initial arrays”) : tor i in Cb): . PAu (0, Gnidss 2s) ‘ vor SUud-array = 6 [3:6] Punt ("\o sUcing elunten: in range 267 "y> Paint (stiad— ary ) ERE i Of2]=6 : print ("Array aftt updation (a): "end =" 3) for t in a): : ae paint (i ,end-) 9) Oulgules : ; eos Array before inbentton + 12 Beo st. ge ye Array Oftr Msertion + iH 2B 1 1: firet eluent id J gi nu popped eltnunk iA: 2 how hadqaq Tu anray aftr poppiag ts: 14 3 1 = Jnital anray: 12 GS bP INRA sUdng echimuntt in range ate. GOR Array affe, updation (a) » 14 6) = Cos :- Clam Nods : df — init — U8df too s dota dt push (suf aaa) ” 22 NOUl- iy celf. Waad * f celf yaad = Nod: (data) ear: nuono ce = Node (data) new nod nixt = selp wad self read > nuonodt ct pop (self): if selp.isemphy 0)" deb Now Qbrt poppednods = self-htad selt-luad = selp huad.nixt poppednodt -nixt = Nomy Subwur poppednods dara cf peek (sey): if sel. is Empty (): sutwur Nor Pe self -hrad data dy diplay (sel}): internods = selh lead TF seb isermply © print (Stack Undtrflow') eat + tolgu Linkrnods | + Non): paint Cinkernods dala ,’-»" end 27 jnternods = internodu-ruUeh 2 fen ‘ —Nami — e¢ fe main’ Ry stack () = Stack ©) i on My cha uk puch (i) ‘ -¢ My Stack - puth (22) yes Ny shack push (33) My stack path (44) Mystack diiplouy ©) ee print (' Top elumenk 14 es een), Hystack -pop U? fie Mystack pop mystack display 1) JPR KE! Pees Nee paint (Top elemunt iA”, ty ckack peek ©) Outputs 44 337222 211-7 Top ehummt i444 22-91 Top elumunt 14 22 Qu-© vAing Unkad 2b implee “ved fnbuild func owt oh Avu: dnnplumunk ng quan uring sel. data =data sult nixt = arxt Clam Unkrd List : clit Smite (elt) Seu bwad = Nom Aub invert (seep clara): NUdNodt = Nodu (dara) TE (setf- vead): cwvunt = self: bead wi Counnrent ext) * current » wurrent wok euend wut = rus nod ehh. usd 2 uanodt dt rentove (self) * temp = sett liad if Ctemp ia not Non) * Clr = tenp data sult ledd = temp wixt temp = Nov pub elem det peek (sey): if (sey tad): current = self. Lead wl L Cetrro -Moxt)* cuit = cunt MOE rotw0our wuvunt -daka : out print Lt (seit): cunt = sett- brad wld Cowunt) : | Pant Cearrint data) : out = CULE, Wh Sa Qurut = Unkedlict 0) Qu inert (3) Point (lelenunt at bu tail uM, Queut- peek )) Qururs insert (4) : paint (i @lumuint ar Hu baile RuCl ieee Qua insert (©) | paint ("es F darquiud 2), Quite Auwove O) print (“Quur aft, duletion +". uuu + Output :- e@umeunt at Hu tail: % Plinunt of Hu tail + 4 Pumint diquiurd » 3 Quit aftr diltHon: 4 5

You might also like