0% found this document useful (0 votes)
19 views19 pages

DS Notes Unit 2

Some Notes

Uploaded by

devraikunal
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)
19 views19 pages

DS Notes Unit 2

Some Notes

Uploaded by

devraikunal
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/ 19
UNIT-2 (Quoue & Linked let) Cue A queue 1 ar Dut G elements 2A which deletion cam J only at one end, called the Pent’ and unserhen can take place only at the otha endl, called thr“vear’, : Bu re abso called fystin first-out (FIO) baks ae ~ a FRONT, REAR, ITEM) adh ~ SF FRONT= 4 and REAR=N, Or At FRONT= REAR+/ then: iirite: OveRFlow, and Retin, 2 Chind new volus $ REALI SF FRonT: = NuiL, Hen: COueus. aunttall, emp I Set FRowT?24 and REAR=1 Else sf RERE = AI, than: ae REAR = 1 Ebe _ Set REa@= REAR-+'. 3. Set QVEVE Freme]'=TTEM Smet ingerte yuo como] 4. Retuyn . = a ee ~ COD ELETE [BYEVE, M, FRONT, xeae T7EM) 1. COs already Enigt, J ~ Sf FRONT = NPL, then: Waites UNDER FLOW andKelarn 2v Set TTEM: =QVEVET FRONT] 3. F¥ind 00d valu How 7 7 a value . ; , 3# FRONT!= eae aon Buus hag only One element] _ Set FRINT=NULL and REAP!~ NOLL Plse ud FRONTS then tan: Sue FRONT: = eM ERONT:= FRONTAL 4. Return. yee 0, r — FIFO (fist.in Fst Ot) — Lbmuitr ure Stored : Varo Operation ) Quour Ove i S 2D Daoton DOurwr Onder flr» Y Delton - Dar = (Sear!) XK Goe front = (front 1) % sice. ioe uy jie er tsa Linear ist on uohih elemesd cam be Yemored at ethn end but at io ae A He term depee 4 a conbectir 1 a ea Moke’, = Dene Cratlar arrn a pomders LEFT & . 2 LEM =NUL Le jnrdical: Ahad o ed i : > Two variation ; y Ip xestricled Aesue. oN ty egal y 3 |__Tnaa]see ] 7 LEFTEY; RRB are Ree a_i Qiks Leet=F, RiGKT=2 PRIORITY QuUEVES > A Prioils Buu a collicton &% elements such that each elements such eet each element hos been assis da priortly anal such that Hhe order in whith Vnysnl are Ahbed 7 proceed. come Hom ths. following aisle wD tn element higher” privity ds proeewed. a Lewsey prrow is (2 Two ehntit caith ue me Ss : procesced, according 2 the ereler in lohich Wig Were a hid crepresentttlion Sf leusé 2 Z demersioval array ee eS FRONT REAR gr" naa es 2 D{Bse ccc kK el 3 a 2 © Dov tee aC 4 | FFF a H 7 $ + SEER eats Py mtly Queue OVE UV Yd Le mallet k such Lhat FRONT EI FNL 2) Dell pd proces th. fort elzmtu in ve x Bueut 3) Ex atwrp * Dyyerlion « — yy Fusert Tt as the veay elomirt in-wo Queue - 2» Le [Add i607 useth Foi PiumBer =k (a) Traverse the onéscay hat vented Aading a rot - ae aor ae N. Trxert- INFOLS TARTI (2) Debt First rode fom Ah. Lat 3) Procem TTEM = 2 Exit. ne Prnted Lol 7 a» wl 2 eis expen als. Abele oe OS oe Linear co, colton Ail. elo Called rode @bore the Lente erdter given by rte we eo node 6 dled tude stor parti Y Suge 24k peldoy raster preld. Cl a Bow Gi o Dip Et a ‘ ia \ sp ) aaa hea | 23 Cc al eit | ahs\eh i sto | J =LINKE: i 1) Sek PIR:= START Farshaloes porrter re] > cohil, PTR# Le, Ne £P#] * 4) Ket ol t= Linn [7 RI | Spent « Searching o Muded Luil Algeathn-senccy (16), SAR] LH, LO tet PRE € siner | 2) Repeak step 2 wohike pre xrvere i 3) If TIEME Ineo [PTL Hen’ Se Loc:= PIR & Exct 1 a fat PR = woe [rr] 4) Sef Loc:= wel 5) extt List U Sovtid ~ERCHSL (MFO, LIVESTART, 276M Lot? Y Cet PIR-ASTART Y) Repeats tep3 hi PIRE MULL DV pe Intel? 7k] ther PTR = LINE [PTET ye Se = Wee FD ; ‘=p7R& Le7t Set Loc!= AWLld & xt é 4) Set Loci= nie sy Baty Memory Allecalion oe = eee caith Lhe ae Oe TDi pera Logi cel, Trusfiat, vohith has oe: Ls cabled the Lat Parvibble ‘pute of the frer-stoege Lib or the ergo BED LINC — Ture is mo evaleble ace Arata Ths situthon is eed Le] AvAi= NOTE 7 a Underfleo scluati vohere ore ial bbl Boas cite sbuctine that v epi te) | insertion its 0 Mintel £40 wing be > Duet at, the beef ining ey NSPIRS T (INFO, LIVE, S7ART, WANE, TIECD y FE Avat= wil, Athen: Wore over fL08 F boot 2 Seer NEW! = AVAIL & Availe L)tk LAVOT D SE jbo [NEWT = TIEM 4) Se LINE INEwd = START 5) Set START = NEW 6) ext. > Inmet etter a gicon vacke INSLoc( NFS ANK, START AVA) va= nerd Ahen: bor iE OVER PLOWS EX Ge 4). 94, a 2) set NEW:= AVAIL WL, LOC » TED and Avalets LINK, TAVAE 3) Sat nfo [NEWT = LTE. 4) $f Loc neute thon: Set Else. “Cot Line [NEW =£ S) Exit Dainese? © OT ne£0 INKL LOD S LINK LL0e) EW > Drutng inte sell Ire Ss! - com tb be imeted ink a contd Lik Ut. Then limmit be Lnsoled Letwan nodes A 36 2 info 2 TEM = ino (8) (START Save PI INS SRT (VEO, LIVE, START, AVAL, 4) Call FINDA (1f0, LIVE, START, DIEM, zoo) 2) Call INSLOC( Mh, LIVE, START, Au AYL, Lol Ti) y Breil z FINDA [IN F0, LIVE, START, TTEM, Loc, 4) IF START = ULL thon Set Locus § Retlom 2) 9f TTEM< (Fo £4 ZART] than (et Loc: = ML & Return 3) Sot cavememe#n & PIR =Line Ls 7A 4p Repeat Saps 5% 6 while prep nee 5) 3f T7eM < 1000 LPTR] Ahm: Set Loc\= SAVE & Return. 6) Set SAvei= PTR & PTR= LINE Devel q) Set Loc:= SAVE 8) Return Deletion from a Linked Lote | DEL (iV E0, LINK, START, AWAIL, Loc, LocP) eee “tha Node nt with Locabre Lac. LICP | B® thé Lucation GF He rode which precedes IN 07 | cohen w is the iat wrote, Locp= ule | jay of Locp= Wil Athen! | Set START = LINE FeTAFTS / Ee: cs “cet LINK LlLo¢ T= LINK Ee0cd | + B gee we Pieg== Avale and AvaiL=Loc | ee ens oe) Ao © LINK S707 ~ CP Lod mai LINK [2ocp INK [Loc] DELETE AWwro, YINK | START, AVAIL, F 7é7) +) catl rinpg One, erate, SrA. 2) 4 Loca NULL kop torte: F104 po Diver 3) oF LOCP=WULL, then: ao START I= Liner CSTHET) estas 4 ‘ L LINE [LocP J. = Lig Lee) gO ef LINK [p0c) = AVAL & AVAILE LY’ 5) bxit. FINE (/NPO,LINE, START T1E04 Loe, L wp) Tin, Loc, 20) [40 OF STARTIZ NULL _Hin Set Loc'=wvl. 3 Locp!= wut X Klum 2) St INFOS TART = TI¢7 theo SCA Loci= s7pp7 2 LoeP=Nwee &ketun SD) Set Savers sre“. pip: = LINEBIRT] | Repeat steps 5% 6 while PTR Auvee / 5) SF info EPTEI= TIEN, then; Set Loc= P7R & Locp:=SAVE & Reluw 6) Geb sAVEL= PTR & epee Linx Lee] ti Y SaF Loc: = AIL faearet ewig 3 §) Return Hetty bunked List - e PEAR Suh Lah 2. are. 2th. lim oy the lat 9 ation Ky A= €4,4 4, - there ws th Loely pe pote bite JF =. Means rs e =O mens ns ton ext Eeanpl f CR Gerwe Pieri Lute Berked hit — EB) a a7 Y, a) ‘ ob} eIETAI &) (lab, (od (a), (ay) aoe

You might also like