0% found this document useful (0 votes)
84 views

Fds All Unit Notes

Fds notes

Uploaded by

prathamesh sathe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
84 views

Fds All Unit Notes

Fds notes

Uploaded by

prathamesh sathe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 19
6 a technique of Finding ie & given Ist oF elements : : 7-7" sequencial Search elements ave examinest ly starting Fram Fivst element parisons fey © Sequencial search 7 TE depends an the location oF el sition then «i! Ori800S WIM be —vequize to Search th ~ Especled nssof compan complenity of sequencial search = on) Te ha always Gnslort spatial emperity= 00) ‘dingy search has Lire compesity 0M) Sich in ¢ suitable Yor searching wen Mig —» cant to be sench elersents 8 ler in that cose biony TAPP Ginovy 209¢r is only opplicable. aber gen nea CPe cn * 3 a% DR igre mathe! makes enposison bet” ‘toy! cement 4 middle pe ener on ora 4 + eda BS i since elements ore sorted , ther companion may he . Rinued with lee [right half of eervent © WBA wi tert bait atements con be selected by j= ¢-1 ERR eq eye bat cloments conte sdlect ty Ye cay ER HD The proceas oF selecting left/right balF Gonmes © Until the elerwent is faund ob elemen| iy not there Jement af ii) test cose: algorithm jusl need 4 campanison if e Gepace athe element ie Found at cemre © Sm iD Tring amplenity = OC ch dreeage wosst cole; The worsst cose behawitur oF e cha Binemy seawch algenthm hos a ape 7 e plestty) Timing Complesity = 0 4sg29) s 4] Searching me i a © vin g 2 Search eghibils much beller timing behaviour. + key > omeyLe] © ae7a¢ right half sdected A)TF ineay search needs Ieillion compon'song © an element in a4 avtoy having Amillion cements ,ahile binovy séaxch requ © Jer only 0 comporitons for some task © No eF Gmporisons fer 2 = 2 Cinillion) 1 sequential /tineos search = 2 (lm amen) win element 18 # = only 20 Grmpanit inde 5 eae ie ctements 38 10 as 40 = a Fey (aL) 29 go lelft balf eelected und + caren PR eect Seeger rere. Pee ee 1 Fat cal ume. ee iota ioned se oeincd seorrch an element cleme hee ine jes ec wo keveoRtnjeen Ria teue seanched © 2m TE coe hee iso. js lero bey Rell pan Tr glement 1 i presentin avrg then rekon fe gree gees, Whe index of tif dig ret Hen burn ~1 : ey. trpat, owl} ={2.3,8,10,093, x2 10 J indicates, element not found eutpul + 3 rene f incor search 4 hirory se trp, ow (Ds [1.2.4654 : : fete . yom utp at wsaeC dren k + rime Gmpledtty sf Abenocer search = OC. ) simple eiponthen, i) Gmpartively mplex cfentten! ieee ce a : ices eal oactaed (ee aed oFlan array i) Ht reputves 25) TE veguhes agen) is called a sentinel. The speed oF sequencral ree eareeae search con be improved by storing the key ii) Dale fs need fo ii) Dato fs required to veing searched at the end of tHe Tray, be Sorted be sorted iw Time Gemplenit wv) Time aemplesity o6n) 0 (Lega) |v) Theretive algorithm vy Reeussive algorithm. PPT TPTTIONIO NATO ET ERM RRR eC RR Sorting 18 8 process oF order in ascending |/ decending order Sobting con be divided into 2) anlerdal sonting Bubble sort, insertion sort 4 merge Sout ore stable Sort 4 heap sovt ave unsiable aiperithm 1 Sa, to be Stable SP eg a in some Sey where qui The soctiny Sorting ifdnties! elements Gs inthe omgintl unsorted St OD Trsevtion sort : “Thi agonithen is one of the simplest algorithms with “Simple implementation + Tnsestion sost + GeSE cose behawour O(n) rl Sort the Mat ustng nsertion soxt istil Woh QTSTe TS TST RTT S TS Pas 1 tes Tl aes Gisele eb ET ts = CeqaleTs[el Pears} fs 6 Gsrete steal FislsIe} fs? Tare a Tate [a Te fe eS] efficient for small values + West case behou‘our OCn*) ., time complenity Space compleaits Space complexity Poss Bulble sovt § this method ppalew sovin Le case the camplenihy Toeah Cie space Compleaity OC) r3 one of aha oF at method tony 284 sontian Surkn ee] show output of each poss wang arrange Following nee in OC [io.oF pastes = no. oF elements 7] Go , 84,76,65, 48.32, 13,7,0,-17 cn) the simplest 4 the most Gubble sort to ing order go ee 16 os 4S 32 13 FO WIE <_ peer hog ys os eH OT ed : 7 now gg ee FOP r o 71 now os ey mF “ o-t mow ow 4 FF 7 4 3e 19% 0 71? Rees aap hee 4 3 6 3 a Be FO ea Hoa es 43 a FD poe m1 6 us a 18% Oo 1p 3 36 4a 9 Fo “19 Sy Pass Bas: fous | fous s Pou 9 9 Ss 8 8 =e 990 0-17 48 bs ae 9 40 jo ys a2 ws dew Jaz as ef ne 0 Le is m we wage sm 75 87 20 13 32 48s F630 gre an 43 és 46 BF 90 9 uincaeeasemacaee show oll the oes 229. S007 USING selecbin sort ne Fin decoding oxen er ritral ovvay fos 1 n Paso: ag oat fy: 9g 6 BH ute rn aq. sost the following 4 show status after every poe using Selection “Sovk = 34 8 78 6S 12-8 Initial ore su_9 We 6s ok Poss | Passa foas 3 Pas 4 fou G “tan 84 65 9 sorted orm, GD atk oop; See ee +Quick sor is a divide 4 Conquer algorithm, “TF pick . ; PIS OM element 08 a pivot & partitions the Ow ; P f oe Give oway orcund the picked pivot ae ae CoN ap CAS _FT8E [lost fony yondom element re GF Pivot 4 sort the oma An Put ve at its correct position im Sovted arn fut all smaller eemenis than ® before ®t ful all greater elements after % Lis sluays greatee-than phiet), [J te smaller than pivot’) egt] Sort the given ist using quick sot 15,8 ,20,-4 16 ,02, 01,12, 91, -2 —> Jets fake I clement [5] ar pivot met) tae se he B20, -4 6 2 aa on — as Cat value 15 Qa aN a je value 1s BT THR Juder they exchorged ) Here i281 WERT auisy 20, fe20 20715, 4 More joa nae eis, # we have to exchenge 20-2 w4.1j2,4,42, 21, 20 “i Gere i 4 TT ner, ge, 18 IY Hoe 22.0% he sem zis oe, else «@ have 40 eachange 16 418 The Rey process OF quitksht /8.a postition given array choose element ‘x’ os the pivot ¢ = (8,-2,°4,10,2, 1,16, 21, 20 ere 9° (nese j WAT ras, $0, 621 WO ies, ates terisy bon veiey Bub Here index of fo 4 % tndex of Here 7 Hence wer hme 40 Inkerchonge value oF (| with pivot. us) 7 oaer2, +402, 2, 0, t6,21,20 Se 7 pan TT phon Jat iF clement = Pivot 16 = Pivot Rg ars tna G2, 21,20 Derara.e ae 7? Tod Pivot intechonge J hiss se Da 3 Piegctast ial + euligle portition @ Sorted No. ore —, x 4-228, 1916, 20,01 7 4 is v © 4] Sort fllowing oe using Gufck core 25, 82,13, 23, 49, 4,68, 88/31 [E] Merge sot * Tre fe veny effective Sorting alapnthe ach har optioa) “ho. oF cermporis0ne = Beinn aac, eet i Prins we hove fo merge 40 sorted Wats etna eon into one sovted Viet we REARS TE har a linear Hene complexity See Ea 31 19,28, 98,9, 65 88,82 qelsiale the following vatog merge soul — wo as HOF ga GF Br], bgat aes att 7 } tt = See os ta 93 6g dope >} ence Pivot inferchonge J... 5s as 23, Gi, 38,65 88,82 itt ox See rr ae. rete ae By oe Wye PRR? Ai. 13,23 cs 2.82 ~ via paar WS wy es 3 419,21,23 a8, 65,89 28 7 13h varie 55. rel 0516383, 99 —~ Z Me? os 11, 34,45,55, 67,85 89,99 ‘The soxted ne.of omeuy.t NF, 21,03, 95,48, Wr ke HC 9p P 2,0, 69,5, 28 WAAAALBRASZ, ow (oa) (3.8) (43) After omay (g's) + (58) (9,4) 2,0,3,4,6,9,8 14 11,20 (sy Cae) igus check chethr swapping it pussible fr Yy Ca.gup pals) Thies poss Hore gm (2 gap puitd.. 2,0 38.4.5, 9,8,14, 11,20 DAA ARALAY ©. 3,4,5 8,951,140 we howe fo make 3 time @ After ony ‘ 2694.5,8,9, 10,14, 20 [ac] oe | v tm) Q Fu sot | | ja — * UT En = M1 pray Linked ist Se (G) ontl ee ) Avay is grouping of Linked tee 5 vga this type oF inked Het Gach nade hells fe pei das f f entil aa, data elements $F Proup oF entities Fras equivalent date type couied nade Node esd ot aa includes data + addess Tt a 2111 owes dla snarls 21.30 stoves omen t in memory Zone svandom'y in mom FH pone er EB Civaulaw Linked tht § in this tupe Fitst $ lott elemests ave ajacene P Vokes Uist con made cfreulay by Storing the + rede nliquaus tnemony. 2008) a) The data elements ane a] The elements ove. not dependent on eoch — StPtndent te each address of Fst node te the see See eo ua Te pcese of eceuing “Dike pote of aeaatg een MeL} at m fares ect tcee ae t 4 etentente bake 21. Tn cate of Lined Usk ) tn cue of Awa ic © emery ubilizabion tie memory ubflizakion % ez] wile sigh pesferen reverse operaltons 95 tearrele three Sty (eed “eee ce a) Wat conte sevesed changing the |The memory sie 1s €] The placement of ‘rection of the pointer again F again The eed is paibe “alenaais 12 altosnted oH rchenge tt using during mun Hime: EINE aging tntist un Hime " TL, link hbk after reyera| fee ne Types oF Linked fore t WW Singly Linked List + « AFter qeversal of To th Wyott inklak tuo succesive nodes of «Be ‘ae node the linked list are linked with eachother int aad ih) after sequencial manne e peered of Prevemaat” in mand tection fe posible Ee \Klede Shell sovt + "This methad makes repeated USE oF Tesertin sont + TE on anay of n cements 15 fe be sorted, sing shell) sowk then fneverment (1) cheasen beFore every. past . a ‘should 42 less than o.di should diminish then e Second posss 12 %y a2 7 Dskepe (ue hove te make 2 gap par) 1,20 Boa. WS 89 ine 2 dis fen) 8) ith eee pots 4 Foy the Last pass di shuld 2. oo Gas) Pl Ex sort the given Ifet using Shel! sort. 9 a9 : Gia £,3,2,11,5,14,0,8,8,4,20 ta) 2 tH) at 5 Garnet eet) an a First pass Sskep8 (we have te make pair afler gap (a0) ofS pale} o Array after Ras aig d Nmiies a 2 0,8,4,3,9,5, 4,120 yay Hath -Chagnteg 6 ya iatleafer cle 8 a ening pt (a,9) (tata 20,8 S14, 11,20 (6,20) a \ (o,4) Amoy Afr (8.9) =G.8) Q Gas) B02 HS, 8,5.1 20 a), Alen arveeng « Again hack Swopping is pessible for cs) 4 tia sy a 20.3.4, 8.9.5, 161,90 et 3 pointer vaviatle ity Preferences linked liek reversed so (or aa] Uoked Viet ax on AT = % fointe 40 Vinked rst te be vevensed Wy Linked Wat ig a thaln oF nodes uber each nde 1 pointe neat node to 4 rth Ge nnst or tue Fielden, « dato fied 4 odds td ie dig ST® a palo Field holds the actual element on tre or , _ ene heat oubvels Field canton the oadees, = COATT, Ser ttc ane na 2 mine Me sas» : : AD The wotive. (enced. 1st ig. acceutsd Fram the sree oitetie Boat had puints Te nates ‘he at “The nest address field oF last nade centeins 9 ‘specia) value called a null + Aull Sn dicas a signals the end oF the 1st A) gust vee a slack or queue, Woksd eur is 0 dato shueture (for = sustct ate Sy] i Joke node From 0 reversing stogly 24] write algorithm fore del Coutetion ‘oF a Node) 7 a Peay, Chedtaner cre Cowen A | PeNULL > 4= head = Y— Next While |i reverse the node pointed 4 T— next = Ps fs * move Pair ferwcerd ty a node Peas taken a node, pointed ty P is to be deleted then x be Tis prodecessor node 4° be tis. siccesioy pede Right link dt x€ should be set fod u qer : 121 next ‘ vend polynomfal vepresen List awith an exomp + Apslynemial pte) oF degree is defined by the expression Ford = dg + ax! + ayxta + ey here an ie real no. Fn fs on integer A polynomial con thought oF as the ordered st oF Mon-2exe terms. Each term fs 2-tuple Containing power 4 coeftietent in vied Py GLL~ ee Feat ned I y3(sa2e de) + Y (sete) + (94 9) Jat Y fe only voriatle then 7 fer coca eqe] 5 4 6x*-92" This polynomicd represented as Coven , cetficient)E | on rae ng hs G53) fosaien.-s] e (tae) cere ara! © Ol st0 Hence the linked representation oF te poljoeml® (ashr3) 18 CeefPicient of Y" -. (0, 93749) ’ Ts GI 3 Er disses, a Generalized linked (st (GUL) + L denotes or sequencial elements bee (hide dase ded al here A= ne. of elements (TT Ha] L foe TE 48 (ovat pointew) JenRaEe - aa 1 (doan painter) ATG WTS cettiont Seer yas fH ANY 7 ET” af ag bare Clut weickat) FNP SAM + DNB aay 4 SUNS Fault Fay, TOR ASE I) 4 (ase VE + Bey oS Cn 598490) Yh y (aut 4 cadet) 4 ory Dake: Abom 2 ony ie clement /atom ther O- net piles ag. 8 PFE SE oF ator ay CMAN TT I nn einer ae plo allocation 4 TE is the process by which Compuler progr ams 4 services oe assigned with 2 Fhysical [virtual memory space Garbage celiectien * TH is opposite of memory allocation Garbage ie memory occupied by objects that ore net in use by the progror” A goubage collector collects gosbage + rekms Ne yenéral free memory Advootages oF Itnked Ist over arrays + Ao array is a Wneos collection of data elements” ahile a linked list ig a lineas Gilection oF nodes 2) Linked st dees not allow rondom access oF date 3) Tn linked list oedes can be accessed only in sequential manner 4) Another advantage oF linked 11st aver ney is that , We can add any novoF elemant in the Wat 4 this is not “possible in case of array. er) Stack a UNIT W* A stack ig a Sogicad concept that consists of & set of similar elements gan ACT —* : Yeo UFO stuctore . “lak it Ue, eS, ng an omy TA-10 omay con be used te hold elements ree osiable ‘top’ fe used 40 Keep ‘eck OF the index of the ‘tepmost element + Operations aocnsted coith object stoc! 1) void fattialize (stack *P) ae ees a stack a3 an empty stack 2) ink empty (steck *P) : Function’ checks whether stack is empty H rebutng | or 0 depending aherher stock 1S empty oF vot ink Full (Stock* P): . fonction checks ahether steck 1s Full J retuins | ovo depending whether stack i5 fall or pot. 4) Tok PoP (stock): The function deletes TTpmost element from the stack 5) veid push (stack *P, int): The function insests element "at" onto the stock psinted by P. 7 4 Sia Applreations oF stack he |) Fermitied operonds : 4.8.6.0... means on — Tees R aa . 1) Expression Gnverston She *feamitted opevadaya s+ ,-.», 1,4 Tem) Serer 4) InFiz to postitx os 8) Blonks are permitted in the exmession SI InFix to Prefix €] Postfix te Init 4] Prefty te ta ix, 4) Porenthests ave permitted Prefix 4 Postfix expressions con be evaluated foster in cmparisen to infix expression becvz| we don't need to process any bvack ects. Algexithen, : Giep '] TF chorocter ‘8 operons) push slep 2] TF chovackes (9 opttator then PoP soo aleroents Prom stock 4 operate on these dlements according to operator 4 push the yeswlt back to stack Step 3] Step 1 4 2 hos be repeated Until she ‘resulk Jend thos reached : Shep 4] The Result ie Stored oF the top ol 21TH ton be used for systemable memory management it te stack 31 TF con also be used to conver! ane fem OF expression te oncther form 4] Function call 5] Parsin: 6] Simulation of recursion @3] Write on algosithm for fostFtx evaluation with on example the stack, —* Th fosthix expression operators ove writkn yeluin Te after ther operonds step s] END for og. ABC +#0/ Hove A,8,0,0 ove operands 4 + fush : Tnsertien *Fon demenk +41 one’ operators Pop: Remeval oF on element Pevmstea + Allow Forontheses deed bracket expression G1] Explain skp by step conversion wing ew Shack For given infix exp- 40 posthix op, St) Has (b-crdy) #Ce-ayec lnfix expression C —~Ne stack ( fostFix (ouput) Empty 7 ‘aad Fain recess oF conversion infin te Postfix a AP (B-C)/ENF AG a + seFix exmstion alate oA er ab 2» * a ¢ * ia 8 ke cube 5 7 eC ac eer y > 1 abe~d ) o/ abe-d+ / abe-d+/ i In abe-dla/ 7 aber dt / 1 abe-t-+/e att abe-ds/e —_—_— abe-d4/eq, abe abe-dslea-s abe -d sfea-#c ds lea- dt lea ace Rathi ’ 4 68 8 Agee Aacm aBcme aoc aec-# nec - + EF ABC - + EF AL ABC~ tEFAIG ABC~ 4 ER AIG + ee SS ee, — ) A” ESTEE ABC FER NGS “wat signs RR Ax Bc EF'/GH Aw (ec) ER GH Ay (ec) E*F/ G4 A (8-c) /(E"F) G+ lA + O71 E)4G | G1) ahat is tecursion ! —» Recursion meand defining a problem in 4 of itselt 3° ~_ @3) Gplain Use of Slack Fer aeeuxsion eta Recursion 15 implemented using Stacks bez activation ecards oe fo be stored ro LIFO evden (last in Fiueh out), @ruhab is backhocking —+ It i a technique based on algo, 40 Solve problem 3 uses recursive calling 40 find S01? eu Eyain Backhacing using n-Queans Problem —> @ Queen is under attack at a we backfrack 4 cha 2 ‘he reve Gene Rsrhone pe ete oF the on tn me, Hey Place ‘Spoil ta pce a + “To implement multiple v - = se ee A ee #ER/G4 a 5] Explain how multiple stacks performed aba positon enowe ar Rep eperations me perfaimect baie = operations ena queue : Give advantages of cixctlor queue over Den @ueue = To insert an elements Cova queue. S)de QueUeW = To deleke an elements 1) An civeuloy queue elements Can be insert 2 deploy 0) Te diuplay the elernents easily aheveas in case of linear queue - fo TTT — reo insertion iS not possible ence the near ia reaches last index 2) An cincwlay queue there “S no waslage of 85] Feplain cincwlargueue stag Link.tis > cirudor queue 5 better thon \ineay queue memory $ Memory iS used propery in a becon there is no memory wastage Valuable $ effective monner as compoxd = Liked 1ist provide the faeslity ef dynamic + linear queue. Memory allocation $0 1 iS easy to Create, = when we implement circuiloy queue usin, linked sk lis simtloy to ctreiay inked “ust expect there ove tuo poidRY Front 4 year tin civculoy queue ahere ciyealay linked list har aly one pointer Head ; 9 difference pints ¥ ,, | ~ Malliquene yeceive Packet queue 4 more than ene brensmit Racket queue fo on interface There ove 2 types of Brovity Sueuce ( Ascending order priority queue + ctenent_—» BLS] Te] ]— Se" oh Sighs (owes Provity Ban W)Vescending order priority queue # cioent_» [oS ET ST2 + erent ra sa Huse Gioeity FO 0d Applitations ot prigaity cover FO —* 1) Prim’ algorithm ¢ ae oe os se Ze 8 Tia implementesion con be done using Provity queues 2) oijkstro’d shoves path algorithm ¢ 3) Priovity queues ave used to Sort Heaps 4) Priority queues ave used in operating Sysem_ fer load baloncing — 5) Prievity queues ove used ty hulfmon, @ (61 Data compression eo Foo Ge] Explain dequeue with insert 4 delete epe~ ations penta on th Pe A queue is a data chuctore in which Ghatevey Comes First will geout First Sit fellows FIFO ender, = Anserivon 18 dene from one end sn queue known as rear end / tall ~ Deletion done from onsther end Known as front end “| Head ~The Dequese Stonds For Deuble Ended queue = Deque 8.0 Linger dada shuchine her the Insertion § deletion operations are porfarmed from both ends. ia i = There ave 4 types of Dayue © Ynput resbricled Queue ¢ “Tosertion eperalion con be one end sahile deletion ean'be pot firmed of quise bath “ends wet TIT Tt. i dade uct \ © ouipat vobicked aueues Deleon epeeation can te prfirmed atenly ee end aie “Tagention’ tan be putyimed fen both ends una peer aoset So “NITE TTA,,.. qerfamed at only 7] Piovily queue — 1b ig a1 special type of qutue in ahich eoch element jg associated with a privity value Jed elements are Served of basis of theit prinity Wighes piowty elements ove served First Reha tape ‘ier Dequeve EE QE] Implement priority queue using anays : — Bicity eueve i on evlension of the eutue oata shnuclore where each olement hos a fovticulon priovity associated esith it " operations on Priovity dueue t Denqueued + Tris Runckion is used te insert new data “the queue T)dequeued —+ this function removes element with the highest pricnity fom queue 3) eek O oF p+ This fonction it used fo get the Mighest priority element fo queue fare cement oF TRE aay GT sive NUE AT Ringe a /S'SBhae arnictuwe aitm & members value 4 Pioity Seaclne an amey oF MOCEHE UAH has a. fixed Sine meastxe | ayiorable, sue’ delteraine the sae of the priority - quese al eny instance | Tnitelly slae 2-1 indicales that the given queue 8 empty,

You might also like