0% found this document useful (0 votes)
177 views46 pages

DSA Hand Written Notes by Anuj

dsa notes

Uploaded by

nimish
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)
177 views46 pages

DSA Hand Written Notes by Anuj

dsa notes

Uploaded by

nimish
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/ 46
| - | ~ me [ose Onir- 4 ATA. Sraver pe et | spot C9 Ena previ. yo” sionisbls i | ‘Ss tell Dnisweblon os) i il a ae pools, wtpicts agli & Operation: ON BRAY, 2 a “ Goi fn betateibbhow —_ -fSSsachlng
| Rw wise a tovege. of 2su10, \ a EEC vasa) Q AnoreeayO | addres of Uj) Iovotion = fs wW Cy Cimb) sey a whew 2 2 4 N= pe of columns. zz cee you. eh a wo hese, addres : Fie to i a f= column = Bie clerisnt, a slowo bound sof 08. yo gual Co o Ke worayeS Ar wy 258 aa il n= % VW-b+1 a ~ahow U,! = Ubon a sed Column - : 2b Ha Lefer 4) Qa] Each Clem! of on aveey ‘DATA a. tate oe ‘| reapaiares 8 bites of if baw Address of aetoy DATA js ooo. Detew Gre the, “ docotion of vawe | PATA, PeDbED crdhen sith s eae We | = he Addrus = B+ W(nG-4) 4 (j=ts) ) loopo = B+ 2 Ctoolle~o) + (26-0) ) 7 B= [000 ~ 2 ( torr) [= iso} a fe A lkoI0257 T T Hdeogs = Bo W Cn G-L)9 CYL) ) | | 2 = Tae + 2 (Io Les) t (20-2) ) { = loro. 1 _ - ~ Aalieea of ~elemurts din, Lap ol 0 89992 évok pa 9) 3 on Q yeas 2” f eae 3h5 8905 _fh wot Suoe | Co humm’ el a Seorages\ or ie Liles che ai ba dios ft Se tsi Aj cleus of (i 4) elemn = Rit Win gat d+ (Oi) o- of rows . “whey om =n | | ‘ dim Ut ts Z 2) a howe! Uy, = Bbber bound 4 Rw Le ta Ossvrra = DATA La Lis] is 4 aH sero Lohih \s_ Stored in = Fro ry, alos thy asnay lpr with each ot cleronts Y oun Ting 2 boy Ses find thy adler, Os cents DAZ “sey fig he” element i ov od DATA Past aLled Ole Lisdoxedor Ge \ Memesyic: Hosa (4G oa, tel © Ting urse te ae re 0 Yay P ang eit a. 87 Soe L Phaale way i : [ ar | EPROUNG. Day IAG a Linear Senainig: 2 t __ | Aégouitnn. til} ) havoc fe Dssuring J] is the one D ogy Lis the Lowubound Pf U uY the up perhound Aresy uot 83 wi deel thee Hora ts be Beosre heel os au Skp 44 For Peblrve i Repeat \ ishepe! of 3. & 44 = A £1) Setar tere = » Pind Seavich ts sutcesful Pang “ Jocation ” % . Borak. | 3. r= T+ wif > © { 4 p99 ®| Pend “ Steoeh Ls Uniw ecasdy | 4 tind. Qe war “secarch’” _Wohic hols Leach Gn element in an Qivey using Uncoy ~ Scorch mithed , jinet'on — shoulal rrecieye__ nF _ Aura ¢€ its size and the ne- to si bie Seoseh eol 24 Dosgy mint me 4 mebuon he Location if theme is Vincanchtel otherroise.” efaahloel le ae 2 { : hod ot : f Gok steels Cink 9-69, nb p pint na) Lint mah foc Cie0sicn gti) fig (is = asia 3 i yefuan VD “3 \f Cue i Yetieh 1) } DW NDSAS 3 Lucowedy sod tin ascend ng [he Lowen bound | pound Fd mm de the noe ty ae io Beg LL lee lash =U tt Wot dg b te. 1 wishes Regs Vs teas thant ual to tack Obey Fridd Not not bund” A0- Girol |i! ol Gil WAP do! ssc. dogs “todas. por with the help. Woof i bincory (reaneh >: tthe ebay 4h te oto show Fsence of @ he tht sho? Vetence of ne in thet esqgy Tre daa al Loree fouarmites ¢ loan Beiay ip Be ne wy ve Sete «3 -> the nos 4. elemits bin Dera Te. fun ay Ase Storeal in, “cen cling oveley Ind ou Ga Ay £9, dak int n) £ int 3 29) Neste nc mid! vohile Ctoeq_4= Lag Doe tr {mia = tg 2 tat) Het mae imag) a te Seelam po L Un 2K py lmid I) — "eet dost =mid=1y 2 [Naves i toy ies Ain deh Ay Lmid I) wo buy! mid tH = x ny ae 2 tt if (og > at) wp actions 2A return 0; ie a Insesition Dlg sit . Assuming Ao ct the | wocay of ge nit Has -Locoewbound Ute the’ upper ound ats fhe ho J ex Insovdedl in _thu_aeeray» - vl t= al if O= n-l "Print" Aney > Ovo foro ” at y : it pig alij rw . pos = 0 ph al ehe while C? i i pos zor Ez E elue : : { £ are G<&) if (tis c= y tA n<=% Lind) {se ; fos = tap t jetale IN C= poi Ue sh)! p Utp. fo shal for Gt ae <3 ty 2 —__} fr Cen ize i Alife Qi Pins Qo . af id= zalil TA. a aE Nite ght ay ae ay ye 7 - Hod 3 ( I err - 1 ° | PDeretion: iota seat wR 2 dpw ID Abcorrrn rye sy'ddsa lh oils put i ‘Assumn} Lise th heer Ipod ef U is upper bound 1s is dh focation whose eltrund . Bitoln toe ollefees tel or t= pos Ki Utt yy) Repeob,\- steps se) A d= a fied ttt > 4 Kyek 2 t= tetra > fuga) Fi ? 4 Qeuer tiei\ e =r ft £ Ende p Q-l|WAE to dellete ony _efement foam pre Cewray —. Function | Should accept the inten auseoy ids Sja% the position whose value joe be dette vod deleter'Cint» £197, nt dn, mb pos) Poe; OD _h = lo Sint i Pe. tél. yor (12 POS pi cen by ei) AL ; {alig=\ALitg. nen-hy 3 7 Voarnis i Gy [Gopece Soar> Avuming |) Fs casey, (13 Te lye Dosey Youn Jus upg bounsh elds \. | fee T= 2 bo V Ppeck sk ps DL. 6 aad Al for T=2 do UA Peg ok Bodo al a. [4 @tsnd < nord x desendng cry we 4] T= pls) Gh B Gis chagal ALag= att) Ataj= ink) (Mg Sioa EE ~——Fypiswsort Gn ol J — f tig ty rept fox Case igh td : fox (y= 0 foes +t y. it @ pus ay 7D) +i 4 m= in Ljtid; ad jul = elf J: “alpJ=T: 3 abo 3 cot “Sorte! ovocay sal 2_ter_ ap 4 qoure atidgis's forties ice, vede © | i Civoit / main iC) Sh \asded wt eg SE pas dn ns for (iso! ign se) Leout ce Erte any nor" + on atiq 3 ow soxt (On) 5 sp wwfSececnon Sovt. Cua ofa | A writes fis oy Ly Soccer bound 112 he 44 thw Se ppin' blind > Mo bbe Arte FL 9 1 mn toendleg srder> \ 3/1 | = Se elu | A] FoR Ist © epat cieps ( | tl Smal) = afiJ , pass) Q 3 for T= 14! 40 0, repeat skp t46, 2, Pl = nf $e a P37 TT Les il a Gf 3 |B Lt fae Mowe 1. @s|'_ [no 4 I ie Sf 3.| @) io ie 7 ) 3 16 tb wD Uc 1 oo 4 s ie : Oy: : 2 = : = uw 7 6 3 f an A Assuniong A is the oyatny, (ojethe faew lhatunth 4 v_ Por boun Q be eek ib eucnaln ant b a fap aaa ape Repest ees ai t= atif 3 FT = int (a tit ‘ us white t pe Soa > a ; Gy weal Bt Hea tor} Hy way cleminls in ascending orslo,__‘ing__issucfion mrt avi iy ofine” a hati ie ‘ise ey 4 its SRe Sah 044 wneth, _ =a {| = eS void oe seta aly info) { th int Ligh td 5 A eCithe ML EC 5 aid 2) J ee ee t=B. en Somme Te dD mn ockayud|| woh ile. Lb catad dd_ Tiree) 2 40H TAIRE OL ages eat 2 Gd ono -crem gee tot t Se ste! “1 Tey? wot 7 ghyah lad fI-® Poesy Geel Deseo _Enoruy "7 pr (ise dns) Guy zoo, brs 3 ¥ Mezquugs. DARE, Sk ve zlecy eet el Br eo Pel alalulu is]34) a) )ia] Ales J Chie c is [ sf ad i) ehdofe Le] Assuring a ak 2 ase ink Taaay ef spe nfm = Finely. ue. have tsi 407 roy both Cso-a4s in aosy Cy a —tk “ byaigys aee_in auending ovd Apte =L ut) Bhs SL Cpte= L while Abty ALA ptxd: ! * Awe pte 2) Abts +4 oe Cpe = Chine | ; “gal while Bpts < m Repel skps 94 Lo. q/ Chepbi] = @ [opted 3 tes ff vow? as hte =) Bbte +1 i 4 LiCbhe= Chiat | e I 4 MM. End vio os | : | 1 Glrpe fo _moge. Suggas ARC aul aseey of inks af. Sige on 5 Lip G, Cele) = phabird — Apr = pbbr +) - wat ris Oirty > Sie s By ; ae 7 ehe a Sy ar tif x0 Echiy] / = [Ble J 7 2 Bibbs 41 at | 3 7 while _Capiy Ginpk mentee eck sae nJ Ton fs ast 7 co fon stack, Pee ft Step -1- Sf (Top == =1) * ie | rink" Stucke wniaine9 | exit 4 ! a ele { Psnt “ Deleted po BA, Sltepl I HEN lop= op- 1. i Ms Exe I : | g: pe in (r+ 0 dele on cle ment in Osa nich stuck _colidh gerieve the coy a top as_on. Conga mint yord___S=bp} Cn sho nbd Top) att iialig Tops =~) (wud ee'® Sock iso nde bv ie the. ‘ f Leo ZC Deretol nor is” <2 S)Fop) » Top? Roo =! i fee j Conwersion O Tuer © pers, (pas) s F/B 6 5 + ABy* f IDE . eb ABE pf — Euvauyshn pee Dos £0 : e -_/>+ ABEDE- a Prec Mo 2uerx g — Paes -/ * + ARFDE A+R ——~ * -/* MEADE yep — y¥ —/ ye VID 2 sy =z m [% 2 A Yipee Xe /OLE (O48 )k F/D- EX Jere Vo _ Yost e Ata) eB Iie LABEL ET Dt Bs = ABA & fy~e SS Pos rére Po Duna 1 ABs © 9 B/E- prays (aig) —— ¥ n i we Xe ¥ O/e- {i . xx6 —Y {i yY Dle- Yilo~= 2 i [Ts = Zé e VID- E ar) yer /D-E g \ Chie) *Ffp-e. Fr Postfix \ “expression ef _the_gven ind ~ oxprension = @ +8) *F/p-E using Shock stds Inedthed Sirigo Sennen.) + Qrace Ex pREION a C C ( | va A ¢ At a ct ct [| 2 8 Ct Ne i 3 ) ABs ¥ * AB+ I F * ABE t / Aare» | “D / pBxPxp | + = = AGI rsp) E - perer0(e Abs ere A+ @GrC~€d/g "TF EdnG) tH, IN At Ag | Ag- Ag-- | A> VIAN seal be ABC Ag-c | AG*CD RB=Cp/ Aga cp) Enea % ne~< pie ee Ab= Cp het UV (W-2)/7X Synpou Stanmed UV AWZ PAN SSRN 41 <<) he “UV# WZ Us WZ- p< Uv * Wwz-x Ove W2-\ft ata a » ., [pares Taal a oe = a /Cqg-e)* § +T ¢ Spor eanve d 2 STACK = Eplressionl 0 = : / Pa C Z€ P q@ iG PQ Ay /C- Py Ro 7C2 POR. ia / pag ~ hy 4 fi a POQ~ Ga BAN PaR-S ti + PQp~Se/ £ POR-S¥/T Po r-St/T+ =O: | At (Cede Ome FY GC tale 6 nc) CBE) § FIG —— i A A + + A i ¢ 7 ae Te a B aCC 5% AB + +( Gr Ab C + (C+ Agc j uO ABCt : 1G Agc+ Ce aGrcs Aect# > + (4 Q # BaCeD * + Ce Cty Agc+D? + Eon +e €} % pecs Dee "] aH ABCHDE+ L * + G+ AGC+DEF The + Caw AaceDErFe 5 Fg ABC DE A eb / a ABCHHEXP At C +/ AGC4 DE+P* + T ABC + Mea sG/t A Ta a Corp) (CeRA)/ Ge Hl @ A : A a C +( : 8 wt) AB + C+ Ae t 4x6 AR® : x(a AB9C 7 x (4+ Ct Abc D aCe (Ce ABcD a yen AacDa 1 7x ® (4¥ AR CDS 2 a a Oe ABCD +” bx x (Ca¥: ABUOKE tg a Cre Cr AROSE A x (tact ABCDYEF j E ) % C+ AGB CDE F+ a AG e Ci 0/° AG CD+EC +E 4 i * Crx/ ARCOKERG : * Agcp+Crst Jot Lea “9 cnet | i Pz ABCD + Ee +4 /erH PBcp sEF EA [exo _os SS lowe) | by +, é (ee DE ~ AGG “ttle Jp 4 as Susan ae avon a ol auk x 4 if ' al ¥*C A ! 8 #¢ AB = ¥Ce Fo 4p D x(4 Sti ABD ! | ) 5 M239 ABD* | TP Aspe | ea ee ARD+KE | = Parnes ii AgDd+ HE, 4 P a ABD E/E F zy a ees é = ARD** E/e- ¢ i Ca sa ABD» -* ElexG i -G |_—_ABD + EFA : ve Apps * E/E~Gh 7 = Ghat a POD E/E GK af. Pept x» Ef Fi 5 cs ppp E/6- Gest : nd fep sin e/Ro Gic/t— e Ary “NOTA. os Not sae morc : pws > 2 (NOT OR NOT eer _OR Re SA Nore \ OR eo, Not BOTS ORAM NO NOL A War SMT Cpa VAI t ¢ “he daoel ns Sard Rab thevew) : rd Pash 8,2 a ae Pop how hoo clement (Or Push dhe desufis 1G | fushy 16,6 eS) econo gem i Ag oo ee 4 42 - ee dive Pop doo clenvns ae+ Ash vath 1Q,g 3 ‘ap htoo ck 3) shes i a ge —— Pag Delouwis(ot a) 7 yy aul Push tw ves 1S Od \a - Litwin vagalt nore O-| 3,1+ O Pot - Oe + FH AYLTIAODS a oPush goat im > Puch * 3! i fop- 9 clemendy : Ruch the geaults ¢. 2 Pasta £2 ; = foo Ho elements iu Dash Ans aauts, aig + fagh ie) il Pula 169.4 hae Poo 2 elements Pasheis sebubh Jo, 3° R 2 Pushy nd 3,2. I oF Jap 2 Clemints ” & Ba 26 Puch fre wewll 1G 16 2 + Jop_2_elermants les = 22 aS fish thr isdult (82205 acs | bh if 9 Push" WAC y eoorl =, = 7 Pop si 5A alan C= posh 19 :, jast_sut) ue yest in ipo? - calle! LILO. ; oe RRAY OMpLEMENT ve h < 7 & 8 = : AigoRITHM: - : Assuming) _is the.» te _Alrvay * imoplemanh of ped pp. Front Fg the sport Oinast” Lestin -Reay is the Test Aocation of the qyutue is the | lem tobe ingen eal fw gpune : Neo kp] 6s if Pe =e hel i Print '@ is overflows ek - j En be. 4 E Rea = —l ] Clea Front = Reo = 0 i axl else { Recor = Reowy +4 j “4 ) [Reoy J =X & ered Q: ll tone use. __deffiie) _funetp to puch elem tng Avwy _ Tglerinect Pusu. Filme” shall qrctieve the. Queue lias ime, Poon Ree "Sa on?" asgumht, 7 sg “Y Ef void Qe fash (int OFT, int Frank , ind? Recark , int ty, inf) ce it C Resse = == nl) aH i cout <<" Quawe 3s __ vere Jovd 2 : abe z = $ it C Reoy = = =D Bi {fiont Rear a = ‘a else ‘i ie Reas= Reagr t ; : 4 [Reo J % : ie fish ivna alls stuf 2 4 X 6 Ril Ht 2b pp hoe Pop 2 cements et Re 6512 Puch hy dubs 2 Push i A ys)2, > ~ Pop 2 elerners. P1Qr Fes7 Pgh avy gusubls Se cS] Push 63 8 + Pop. eleropts B58 ‘Y fash thi yesu ls 8 i 2 Push AB ts fw | + Pop ke Chemayls ; S| Push tre ves 1 16 | £ Push [6 7 _ op 2 elemnts [eee a fash the gaits ML J Sse getae gees perce , fap Qelemnls 7 I fash the tult aD 2 Pop Q elemats Jade The saw' a2 aa Push QQ ar = fap 2 lems Pash Ww rail “94 8 fu BED ‘& Pu eis Bee y ee a Lg 2clemuns Dale § i Dash th vault 4,6 ; i S fush ates 7 * 1 Pop 2 clermints bowel 1 fuel thy eth ey - Pop 2 elemints aeal=ao| Fesh To awit 86, mh Deerimw Tn Area Picconitm) ele} = Yoong 4 vata | Assuming thes) epaiays _implerunte hy gy nh Leone" fort. rrosd! bb co Yon Rew is & le Dost rae} eqpvalre dora flon't 34 Exon =I Qrint “Quave bc ‘usd eile ” ot wl elge’ fore | Print“ Deleted gLFront J 1 if | bei b= Rein Ise. Front = Fant +1 end t i wk wi) warp +o cklete lent _in adingy imple merr-eol Got te veid h- Pop CA OL Lint Cron t | nt4Reor ) fo 94 Crront = 2 >t) cout << " Quewe 4 ‘role flaw mC else : t Licout cor Deletedmoe- is” “< OLfeont? * fig Cron == Lewi) Lie Bont =| Rep, + Rees & else Foot = F yont it hag Prot = Reon = - 1° } veid fash Cyd)? vor fp C)s: z voi el dipley O; T AD 9] fone” definrtion af “Pach fob ard ool oid uuue '' poh (X) Lif. (owed) 9 - cout <¢ “sg Lod, elve Lig (xe 1) _ front = eon =o} “else FLOM = WOH+ Crea Js X) tout << msg fd che as & ToL if coup 5 Deleted tno 6 pep ont Ds Tine i¢ ely & fe Cit Faoht ; TCE Oa p44] font = foodie ly! 3 coup ee GLY; 3 3 Voi Gurr = AS wy 3 Cecocag Qveve Assurning C,-G is atthe. Cietu loa Oust of clze Font UO ig frorrk mart _Jotation Ress fx eda ‘location Sink = NULL? Just —> Jinke= Jest = %; i . m=firtt; cobile (oct = nute) Scout KD info j a= xin ky etch) i Linke Srac kK QDuseotion Step t:-|| = ew node + ame Qo w=? info =< Tem [x tink = Nolte gol TO = NyLL ; Tops x 4s else 1 1 Jink= Wo pan trd z | | AF fo IPsouk on cleront in Stole Chinked stack). Stouct node Lint info p's Ingle —# Minke wis at ct Yea Stas} vei void 28 Push C pale tap, int item ) SA node: #935 i KE pew der is X— Indo = item ; wx Sink = ULC? i s Decetion E ‘ ef _ Seni} rf Top = NUL u | Print “Stack 2¢ -undertfe w" | Cait ‘ { Qyv else i Print“ Dele nor is” Top —> Tnfo ‘ 319) n= Top wa) Tho = Tap = Sink or ce Ain le So) delete 2% 63 end ee = —Cispze wow) cont Z™ Stucke ty —uedefoa” I Snia ] else. Leouk 2" Detaed no: i : ti We Top) : “To p= Top p—lnk t delete 1 I. Asso Qucie. Dns e ong 7 cae X= new pode R24 > indo = itm. se robin = NULC. 82 Jf Rea = NULL Y Reat= Pront = BIS Ys oly. Reo > tink < oe east = oe eS Eunetron, bong VOl dl ony fares pC jade» Fein) sok Roan) * ; {pode ye we nee “norte vidoutiee' Prter ahiy por (yu nr ml? Tn fou 29 yw dink = NUCL at C Rea = AIWL) Reon = Bont = else: § Reon > fines =a Reas = %» : r : “| Deveron | ; [Seo ts Jf Feont = NULL i jt Pind ~ que 1 undoplns exit I Ne else Point “\ Deletet po: is”; Event nfo z we front r eont = Front a bok 3 \ t oa delete oe : is HSen aus 190, & er Cinadh thea 7 fe ae ¢ Front ==NULL UF couse dict awe i vif lo ue else = 4 cout us Dele her pe” Ke Form >} , oc = we front: pind Ponte”. ay) | 28) ht =Rea = Not } mye Apont = Prord> Tink’ sw Se iis fi ——____. | Write fhe bn Jon into Hindi ya “cklele cass An oT winave a py x00) Nor 6a ts _Gnsideitng jhe Gam = wile ous Ah frat Poeket ni Id. a chon addweis [of fa Ket -¥ fink « 33 A { Meket * fron 20) +R unc? “jae eet [fer NOLL) Reot= NULL; 5! wth J void embelerctackeet C12 void dlalete hcleee 0; = due ©; veid Gut m deleteprcket ©)! ol { peut id cout + 5 AB~CeD Aas a+ AG+ CHD (0 E +/ AG+Ce DE 4 - Bb - A Bx ¢¥ Ot > FE = perc « Low dh ae nes cD +P — LT Ans ll Shuct STACK { B 5A tom Pineode : a Sa Naw_P2a)* u § p S7atk a winks | Cy wold Ra Ce TOPd) bangs Snead chore Nome) c= - e eae te MIAE IS -waTORR PP g ele . a Y courde" Enter nom, 2 pinende of city" : owe state —> Pintle >> Ate > Meta n indo Pinte 2 ~2Nrfo = m + u— Sink = ntuce: if (Top = =NULL) Top = %"

You might also like