86% found this document useful (7 votes)
21K views32 pages

DSA Hand Written Notes

Uploaded by

akshaykahare2
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
86% found this document useful (7 votes)
21K views32 pages

DSA Hand Written Notes

Uploaded by

akshaykahare2
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/ 32
NWVVLELELE LEED ddddddddddddddddiMiwy Data sraucture Anything to give Information is tailed data. Ex Student nlame , Student Roll ato. Types of Data structure There are maloiy tuo types of dota Structure [para sraucrvre ] Reprecentarton of dara is cabled structure Ext Graph , Arrays, Ust + Data Stutture = Dara + structure. + Dara struuure is a Woy jo Store and Organize data so tat Tt tan be used efficdeany (butter woy ) + Data struture is a vay of Organizing all dota items and relattonship to eath ofner weomag Cunkeoi) Primcrive Non - Parmamnive Bata sTevervee) Dara sraveTuRe Prtmttive data Structure :] These ave bade Stucure and are dirty operated by macklne Instruction Ext Integer, Foal, character. SWVLEVEET [Non- Primiatve data chuccure | 8): [elemgtog ] tombioing thi data of tie different stored Flies tato q “Test are derived from the primitive data Singie stored File different type primitive data structure « ont In the data structure so Ext Arrays, stauc, trees thot each data frems fs traversed ov visited Data Strudure Operation The dora OWuh is Stored in our dara Strauuse are Processed by some stt of operation) * fn Array can be defined as an infinite cortertion of homogeneous ( stmliar type) ) GEnserting Aas a new dota in tre dora elements. shuuure- Array are always stored ta consecutive 2) [Peieting] Remove a dara from tne dota Cspetifte) memory tecarion. strucure Arrroy can be stored Mumpie values Which Arrange dara increasing ey can be veFerenad by @ single name. decreasing order. [Reraingd Fio0 tne towatlon of ata j [Fires oc manye J dora Structure ruc Kame CAINIEEDIN, SWUVULDULELUDUII Idd IIo dd ddd dl 2) [Mun?- Dimentonal Arrays t Muitl-Dimentlonal Avraye ase Mor then one Arrouy subscript to describe the Arrays elements fh eV ETC + INS Use only one subscript to define tht elements of Avrays Two Dimentionad Arrays: [row] [torumn] TFs use two Crow] Leone) subseript, one Subscript {0 represent you valut and seond ubseslet 40 represent tolumn value . tt malay use foe mareix — Th ts aico Known as One ee) Declararton + ata -tyge var_name Lexprsclnll p ectaration tw20 Dimenttona) Av ioe ey Dara-rype var-name Crowds) isan Oa eae i. int num(s) (2) mtHatfzation 2-D Arrays Anitlatizieg one - DimenHonar Avvo es ota: type vay-name Crows) Ctolumn)={ values} 5 Dara- type varname Cexpression]= {values} ; eS oar st) 4,250,569; E exi— int num Col? {1,2,3,0,5,6,7,8,4, 0}; int num CIT I= {1,23,4, ono als] = A", 8 ; prt Kemak CLNIEDIA) \isite a _Progsam to read 4 write ont Stacks (Date Structure Dimentlonal Array. . Include < stsiosh>-— pramays tnnapout Ye Stack 1s a) alon - Primitive Unear dara include < tonto.n >~ F Strucrure- — toncole Saput out Cire (ro geteh y [to Tt ts an ordered fist tq Which additon of vold main (7 Neo data item and daerion of already existing i data item is done From only ony End Known as Tép of stack (Tos ) { Yor all i; crs} : <— Push Pine é (enter tre Array elements”) 5 Por for (iz0;, 1<=9; , f+t) aes © ceane ("43", altl); ¥ Print € (“the entered Array 1s”)5 fox (i=0; ie=a; f44) {ante ("ra\n", a f1]); Je The last qdded loment wil be the Flyst to 3 gech 075 be Removed From phe stack. Tris 1S phe reacon stax |s Catled Last-}n-pivst-out (L1FO) type oF thst. Oferattons on Staci There are two operation of stauk. 2 =a po Sam @ ned element to the top of Stack fs called PusH Operation Every new element is adding fo stack top Is incremented by one Tn case th array Ys Fall and no new element can be qdded it's called Stack full o+ Stack overfiowW condition. 2); [POP Operation | + Tie process of atteting an element From tui top of Stak called. PoP_oferation + After every FOP operation tre stack (TOP) is decreminted by One. Stack has two Operation 1). Push operation. 2). PoP operation. 2. [PUSH OFeraHONT THs process of adding a new element of tre top of statkK 7S called | Pusy Operation + Every Pus operation Top Is Incremenred by one * In case th Array ts fun no new element igadded - this condifion js called Stack Futt 0x Stack Overfie® tonaiHon. « Te there is no element on pr auc Qnd pu [AF Algorithm for Yncerting an item tnto PoP is pexformed tren pis Win vest Into Stack underA0d Conairion. Vestal fat Staux (Pus Operatton). SWUWVUUELEUEUU II Idd ddd ddddddddddi% Posy ( Stack Cmax size], tem) Step: initattze Sot tops) Step 22 Repeat steps 3405 until Tepe max. Steps: Read em Srepyt Set gop = top ty Step $: Set stausUtop] =item Step 6: Print" Srauc overflow" 2. [Por Operation s The process of deleting an element From tht top of stack is called PoP Operation. + Afrer eviry POP Operation 4m Staux To? is detvementtd by one ToP = Top -1 © TF there ts no element on th Stack and thy Gee operation ix performed prun gris wolM resulf jnfo STACK UNDERFLOW. condition x2) *Pop openamen!_-+ POP Zodelered [30] Tor=2 +t Algorithm for deleting on item from tne Stack (PoP ) PoP ( stack Emax Size], tern) Reprar steps 2404 until Top 20 + Se trem = stacx CTF] Steps: Ser top = 40p-1 Step4: Fring, 0. deleted is, Stem Sep: Pint sta under Frows ‘Stacks (Prefix g Post Ftx) » tahese tne operator Ts weltren Tn berdeen tha Operands. Ex ATB 4 Operator A,B Operands 2) [PrePix notation] In tis operator Is wvitren before Pri Operands Trts also Known as Pallch nletatton exr +98 3){fostflx notation] Th ents operator 1s wsttien after the OfeTand Ir fs also Knowon as SurFix Notation, ex ABT To? =Top- Foleo tee SWVVVEEE KEELE SEIddI IE dd ddd deers Q> Convert the forlowing Intty to Preflx.and [Postftx > (a+b) x ¢/0 + "F/G (08%) & c/o + €"F/4 postllx Por (A+8)* CID +E*F/G AG Prefix ® (A+ 8) ¥ c[D + ENF IG Let AB t=, + ABR CID TETEG Rix cD + e%F/q Let £AB=R, aie CID FERDIG Rix C/D + ENF Let Ri ® c[p+ MEFIG Rik C0 t lq Let > NEF = Ro Gi CO + Ra JG Ry YD + Raq ker cos = Rs Ry K 1D + RIG Ry € Ret RalG Aura sed = Rx Qs ® Ra +Raq] Re Rs+h/Q Ler BGs =Ry RK R34 RG Ri Re + hu sta [fat =u Gass res e R Uk Bs Ro = Bs | hee Rs +Ry Ge ROR Rs Rut Now enter tnt valve of Re, Rus, Re, 2, Re Rut RRs KR + Agr co fart AB + Co/¥ alt ows nner tne vale oF fs, ba fs fe By Ek tAglco/nera using pobuiar form 4 fo Convert tn Preflx Folowlng operation Program Ys Reverse te inpu srying 2). Perform tabulay matnod and lind post ft exprestlon« 3). Reverse thls postélx Expresslon string to Find the Prefix. Ext ALBRC First te ada branthes (a+ exe) Reverce string (co“e+a) Prietiny A> highest HK, 2 nighest Tabular Parra [Poste s hd Seanned lexPresston| <¢ c c OF cB Ce CB c+ BRA c KY So tha postfix Exprecsion ca KAT Now yeuerse tris Expression te ger the prefix $0 prehix 16 FAKES ges, x Convert postety 3 Dive perform rabular frm (A+B *C) = [Symbol Stanned Sra] Patt Expresston a a AS as Age agcet Insert 10 geo ¢ Feo 10) + Queue ts a nlon- Fiimitive Una data =0 set Rear Step2.2 Set trem = Queue CFront) Step2: Repeat steps F405 u Steps: Te front = = Rear Rear < Maxsae set Front = =I Su Rear =-) else front = Front +) Srepas Pear, alo Dereted te, trem Step: Prat "Queue $s Empry or panes Step: Road Item Step ut if Front ==-1 phen Front=0 Rear=0 else Rear = Rear + | Srp 6: Ser Queve Ley] = trem Feint , Queue is OverFiow MOWWVULLE LULU III ddddddddddddddiM 3). Each Hme a need element Is Inserted Into phe queue the Rear Tx ncremented by one ae A Circular queue is one In which the Rear = Rear +) Insertion oF a new element 15 dou at tnt very [u)> Each time an element Is deleted from the First jovotton of the queue HF the lact location fquewe prt value of Froat Is Incremented by ont of queue is Full ard. en Front = Front +) Fee-t vert an dement in Urailar piew Gy Aigo > Gansert (G0e > Item ) ay ‘Sree 1.9 1F (vont = = (Kear) 7. maxsize) Orit quewe 1s over Flow £ Exit. 4p A Circwar queue overtome Hu Problem oF Else: pote the value Unuttifzed space In nay queues Impiemenred te ( Front = =-1) ag arrays Set Front =0 Rear =o Rear=(CRear +1): maxsize) 1). Front wilt aoays be potnting to tre First [Assign vaiuel Queue CRoay] = vatue element feng te]. ory 2): LF Front = Rear tht queue wh be empry- 2 MNUWNWSLELELELDDI III dddddddddddd dll Queue (Pata Structure) OPeratton on Queue Shale il a: Maxsize =3 10, 20, 30, 4o J) Freok => emnry queue Rear ==1 + 3 4eS Step Repeat R < maxsize -1 <3 Stee Read thm Read 19 se q[o] = ttem Glo] =10 qa +09 4] wow Gerald va a + Yl = 20 mae ¥0 90 ta) Fro, R=] Ja) Reay < moxcize -) Reet) Bs iti =2 Su yi2)= 30 10 [20 [30 ] +o 409 969 Feo, Qeo easy Rear < maxstee -1 2e5-1 2<2 fase Jurue ts overfiow MW WELLE Idd ddd sdb ddddddlllllr Derere an Element In Clyewar Vueue : Alge: Qdetere (Queue Lmaxsize], tem) Dit Ceront = -1 Lyi queut underflow and Ext item = Queue Lévont] Ye (Front = ese: Rear) 1 Front = (Ceront +1) 1 maxsize) Lend 1¢ srorement ) — Ttem delered- 2D. trie Queve ( Data structure) Deere operation On Queue. ext [yo fzo[ze] = Maxsize = 3 61 90) 92) Feo , Ren prac Kemak CLINKED IA), ave 1). J. F>=0 O>=0 true a) set Item = q [0] Trem =10 ae 2 Forse €1se C= Pty 6-041 =1 Ju). trem ts autres 10 Ts dared 20 | 30 Ye) 41) 302) MWWVVULL LULU o UIST III I edd ddd IIL Lakes spe Fo=o WY Trem Vs daued 1>=0 true trem = vli7 a} rem = 20 iee Rg “i False eA Mates Aur 15.4 dynamic dota structure pret Tat No. of noses tn a Niet fe not Flxed e tre and tn grew and shrink on demand A Mnked Mut 169 Mneay dara strucure In nich qe elements are not cored at Contiguous memory Location Srem Ys aeared ao fs duutd Each Clement ts cated q node woth has 25 Sheps! Yueue 1s empty] +00 parts. Fea Rea 1s MnaerPiod. | fnfo part wnich stores qne Information Cased) and Polar wth point to pri next element. yp F> el] 2 pe corre fate [peinter | ex: [10 [i234] Info “Polar 2 them = Y 2) item = 30 Es eee Par }frrg 2==2 tue set b=! Uf se] eat pase wom (ninceoins). WWVVUEEKELEEEIIIEIdI SEI dd ddd lll Arduartiges of Unked Ueto Operation On Naked LUst? 1 [Gakes Uist are dynamte data structure | Thu Raske operarion to be Performed on tht ‘That is, they can gro and sheink during | Linked klste are tha exeustion of a Progyam. : 1) [ExeaHON] THs operation ave used te » Creare a Untad Alst «in Ne node 1 Here, memory ts not Pre-ailocared. memory] Creafed and Linked fo prt another node « 7s quecartd Whenever 1s repulted. And ths eatuarta (Removes) HIND THE no longer |>9-[Ensertion] Tris operation 3s used go Incert needed @ ned node In tke Naked Nuts A new node may be Ynsertes AF the beylnning of @ Linked Ast Tt Prouide Pladbitity tn Inserting @ dara [4 At tnt nd of a Unies uct Siem ar q spedteted Positionsiand duerlon of [+ At HM cPeules postion Sn a Kinned Act. @ data trem from mu givin positon z{Dererton | Tis Operaion tc used toa 9 i dere ‘an trem (a node) From tru Niniced Nist. @ node u): Many tompiex Apputattons can be eastiy [Moy be detered from carved Out clrm Haked Mets- + Beginning of @ kinked Atst. ~ End of a Kinied Aap + spedPied pouttion tn phe tier. No WWLULECECECUCTTTITIS Td ddd dh 4%) Tr Ts a prowess @F golag phrough ll IRE nodtt of @ Mnked thir From one end yo rR Omer end 5)-[Eencarenarton J It's te process of te jelning PAC Sttend Mist fo the end OF Phe Arst Net 6).[Disiog 2fTRis operation ts used to print eath and every nodes Ynfermarton « Tyres OF Naled Uist. + Basteatty , there ave Gur type of Naked Isr 2 1¥55 one to wnicn auinoaee axe Jinkid Rogerner In some Sequential manner. it ls oso Called tlacar_ doled thir [sraer | _sfie a 2.).[Doubly - Unked CIF ] [t's one tn whith all nodes ave Inked together by multiple Inks WHEN pslp tn accessing both px successor nose (next node) and predecessor node ( Previous node) within phe Mat Dds nlp 40 traverse the Hit In bre fortsard alvettion and backward “nseet_ First (ster, rem) StePLE [Cheuk FOr Overflow] IP ety = NULL phen Print overeiow elt eise Pre = (mode #)manoc (size of (niede?) N Create new node From memory and Grsign irs address to PTR Ser PTR + INEO Set PTR Next Ser START = PTR them sTAeT nodet node2 nodes new node. Arter InserHon fw] oR) omen Cuimicep iat). LINKED LIST] Tnsert a node at phi End Yn_singly Wared, Algorimm > IN seer_ Last ( stAet, TTem) Step i: chew for overflow TP Pry = NULL thon Print overflow exit PrR= (Node *) maiioc ( size of (moder) 5 Stepan: Ser Pre Info = Them [Steps: Ser PTR + niext = Nuit > Srep4: TF start = Atle and thin Str START = Pry ese, See LOC = Sravt Steps: Step 6: Step at Repeat step 7 unrl) Loc 4 next! Insert_Locotton (staet, 1rem, Loc) Steps: Cheuc for overflow If Pty ==AuLt thin Print overiow exit else Frr=(Nose-x) marioc (size oF (nose) Sttp2: Set PH > Info = Trem Steps: Sf start = NOLL phon Sek Ghart = Per Set Pty > Next = NUL Step ut Inltiatize the Counter T and peinter< Set PHO sur temp = start NWWUVLELELELEDUT IIIS II IIIT SLL cergr Ager ane seat desee [ Doatng Nowe Bates st] StepF Se p= rth Step RE Let Ptr NOt = pomp 4 et Dereting a node from tha Unked st Srepar Set temp 3 Next = Py has three Instances. Ae Dereting tre frst node of tht ee ' Lnwa ust = 22 Derrlng the Lact nose of tr nad st Arter Insertion Ba Datrertng pu nede from spedfiea PostHon OF pre Aqiad Asp. 2] \s eee Unked Ust Dereting alodes] Derertng she first lode In Singly Unted tist —<—————— ee Linted Use fereting nloaes Detutng the tact node tn singly Waleed Ust Algo itnms > Derared first ( start) Algedinm > Stepr: Cheuk for under Fie If stavt = nlULL , fran Deteting ( start) Step Lt cheus For UnderFiow Tf Start = Nutt thin Print Linked Hick 1s Empty Print Gowed ist emery exit celt Step2t Tf cravt— nied = NULL bun Suk Pry = Start Step2: Suk PIR = START Step 3: Sek START = START 7 Next Step Ut Print Clement detered 1S Pry + info Sree s: Fux (Ptr) Set start = not Pring element duered ts = Pte > Info Free (eTR) Ena le Step3? Set eT = staat SHEP UE Repeat step S and 6 untt) PTR Naxt) = ALL Step St Set toe = PTR Start NEUSLELE LULL TTT T IIIT Id dddddddllllF Step Gs Set Pre = PIR + Alext [Esked tise“ Detening nopes] Step 7: Set Loc + Alext = alow Step 8: Free Cere) Derettng tre odes Fromm Speci éled Qesitton in Singty uinteed Lise [seaer] we oe Atgorttnm > Le — EE Detere - Kecarton ( Next Srepes See r=t+1 Lunicentny) SreP3: Print Clement dererca Is = Pry = Info Step 8: Set Tempo new Seepat Free Cet) Sta] Temp fe] EH TRees IN Data STRUCTURE Tyee 154 non near dara strutrure Th Mich trtms art arranged In @ sorttd sequence + Tk 4s used to vepresent Wievarentcal relation wip existing Grmongst several gota Yr pa Root Levet © et EEL tet fe Je] [4] fl After aeletton. Th tever 2 Gl oo Levers vee Tevminoiegy ] Hee has sifFerenr reuminoiegy such asi 4} 2) [ROOF] 1+ 3s speciany designed data trem fn a tree. Tt is the Fixst In me hitvarnicnr Arrangement of data tem. Josey] Carn dota trem tn atree 1s called @ nodes th tht glven THte there axe 1 nodes sun ast A,B,¢,0,€.F,4,4,£,7,«,6,M NWWWULEU DUTUUUT TIT TTTIITT II ddd ILE 3)-[Begree oF a node :] fe 1s the no. of subtrees | 8) The entlye tree struuture Vs Levelled OF a node Tha given rvee Th Guth @ Way that thy yoot node is aloays The sagree of A= 3 NS The degree of C= : f pe Tt 124 connecting tine of two nodes. The degree oF | = 6 snahTs, tht Hine dyaion From One node ro w)-Begree ofa tree] rt te te maxtmum degree | anotney node fs called an Gage, of nodes tn a given tree. In the given tree |to)fParne]tt ts a Sequenct of consecurtve edges the nlode A and nedeT has maxtmum degree(Z)} From Pu soura node to PA destination node. In mw oluen tree mL path bo Aand J is as. (a,g) GF) ans CF, 3) Reo hts, So the acgree of 4708 TS 5: s) fRevminal nesed] A node with aegeee 5070 Ts called Terminal node. In given tree — E,3,4,1, kK, Land m are terminal node uy Dewy se 1s tee maximum evel of any 6)-[aon- Terminal lode a] Any node wnoce | node ina glven rvee: In th given tree, tne degiee Jf not pero 4s called non. revminal nose) yoot node A has +he Maximus Level Tn oWwen tree - 4,8,¢,D, FT are wp [Foresr] tt 1¢ 4 set of disjoint trees. In a non. revmingl alose. givin tte TP you vemove Ite yoot nose gen It a) [Sibitags =] The chs nodes of 4 glven parent | bevomes 4 Aovest. In yt given eee, Phere 1s node axe Called £ibiings. They are also | forest wlth three tee. cuth as. Acter yemaving rect A. Foxes 1 called brothers. In +he given table = B,¢,D are Siblings ef Parent node A + ZL art Siblings of parent node D. SWUVULEULUTUUUT IIIT IT Id dd ddd d/l Nl [Brsaey Teees | TUPes oF Binaky TREES] + Bloowy see Ts q Anite cet of dara trem | )-[ERU Binary Freed] A Blnasy tree ts Furl J a i ig nese has 0 oY 2. cnt Londen Is elther empty of tonslits ofa Te aa 4 Single them caries yoot and te alsjelnt A binary Tree cated pra Leth cubtvee and yignr subrree- complete binary tree TF @it levels ave comprorely Weuel has ati Keys as Left as portale Th Binary tree, Cutry nos can have moximum of 2 chhidern talon are known 4s Lett chia and Rlgnt cwlid. 2 4 & LeFt Subrree 3). [PerPer Binary Tree] A tree In wxhen at \nfernal noses has two exhidern and alt leaves are at same teuel in which an level nas 2° Nid. tee ated ES eve Level a at w Level T4 9P = prt epman Comicon): NWSE TWaversat of a Binary Tree Tr 1p q Way Th WNC each node fn the tree Ts upstted eaurty once tng. sy stamalle manner, Tere ave three ways worl we use te travers a tre- Node Leg Rlgar 1 - Pre Order traversal (N | L | QR) 2- Tn order traversal (LN, R) S- Postorder traversat (LRM ) 4. |Pre order Traversod :| Th pads Tyaversal muthod, pat yoot{n) node 1s uisties Finck, thn fhe Leet (L) subtree and Finally prt algut(@) Subrize Algorfimnm 3 Unt! alt nodes are tyaversed — Step 4: Vide root node Steps: Reanslvely traverse Lert subtree chep 53 Reustuely traverse Right (Ae voor £& ©, G8 Of © Pye — order tvaversol Is 4 A,B,€,0,C,F 4 |2)+|Inorder Traversal | In tis traversal mumod, ps Lefriisuntree 15 visired fisr, prin pe footl) and jarey te ‘ te Algodinm > Until att nodes are traversed ~ Step 1: Recuvstuey traverse reft suneree » Shop 2: Vidlte yoot nose Steps: Rearrshiely traverse Rignr subtree. Binary Search tree (6ST) Binary seaith tree Is q node- based binary HARE dary struuuse wonkcn Kas Me forrowing Rue 1)- TA votut 9¢ tu ey In thu Lert oxlid or | tnoyder Traversal ts — Lee Gubtree TS Je6s Man tH dalut of eee 000 3){Post- Order Troversol ‘| Tn sly method 2). Trt Volar of tt Key In gra ylgnr extig | 4nt voor node 1s visited Kast Aine the name of right cubtree ix more than or equal to | First We traverse AUPE) subtreg , then tht the yoot: | vlonr(2) subtree and Finally tht voor (ino de, 3)- The vignt and left subtree each must Algorithm > a4ce bea binary searth tree (BST) Step 1: Reuyslvely traverse Leet subtree Step 2s Rewrsively traverse vignh subtree SHps: Vist yoot node. oe @e— veer X S 06 ® post ordey Tyaversal 1s — D.€,8,6,4,C,A prac icomek CuMKenia) « DIFFERENCE Between srack STACK Te vepresents Ha tolleetton of elements In Last fy Fist our (ute) order. + Objlurs are Inserted and vemoued af AE same Und Called Top of stacic (Tos ) Tnsevt opevatton 1s catted push operation « Derare opevarion Ys carted Por Operation. Tn Stau there Is no Wasrage of Memory space Plate counrer ar marriage Reception 1s an Exampie oF (STOLK, Aruc eum ag ConKeDin). dnd Queue Quveve 4)- Tt yepresentc tat onation of elements tn fist In Fist out (FIFO) order. Obstet art Inserted and vemoved From iPfevent ends Caled fronrand year ends. < Insert Operarton fs caned Enqueue Opeatton. Delare Operation Ts called Depueue operation . In Queue there ls a wastage of memory paw, Students Standing tn Q tine or Fees counter 1s an example oF Queue. NW UVUVUE TUTTI dl [ Diteerence Between Smaty ¥ DouBly LINKED LIST 2] SINGLY LINKED ust D- Sngiy Untes Hist has nodec whth dota fidd and next Unk Fleid (forward ttnic) Data [next exe 2)- Tt allows traversal only to one Way. 3). Te yequlves one KIat polnrer varlabte (start) u) It Oeuples hess memory. 5). Complexity of InserHton and Dertrton ad mnoin positon 14 On) gruc eomak Clincedint) DOUBLY LINKED List 2). Doubly Linked List has noses vatth data field and two pointer Field (Baxtward ang Foruord kink). tex: [Prevtoud Dara [next | a). Tr atlows @ wo way tyaverse! 3) Te requbres two sr polater uarlabte ( Start and hast) U): Tr Ottuples more memory. Compiextty of Insertion and peterfon at Knovin positon rs OLN? Diererence RerWween) GAR Z NON-LINEAR Data sTauctuRE LINEAR DATA STRUCTURE Th tis dara structure The elemenrs 1) art Organized INQ ceqyenus suth ac: Exe Array , Stak, queue ete- 2)- Th Unear data structure stngte tevel 8) is Invowwed- Tt is easy to tmplement: Dara elements Can be tyGuerced tng Stngie Run ony. . Memory is not utilized Ina efficient way. f5)> . Application oF LUnear D-s- axe mataly in 6) Appiitetion softwere deveiopment Non LINGAR DATA STRUCTURE Th is dora struture dora IS Organized wlrhout ang sequence - ext Tree, Graph ott In lon. Linear Dara structure multiple levels are Involved. TEAS alefleut 4o implement. Data elements can't be traversed In 4 singie Run only. Memory utilizarion In an efficient Way Appilearton of non- Une D-S are To Artlelel ad Mnteuraenu and Image Processing « SEUVUC EEUU TUTTI ITT IT Idd doled ha [[ Differemce Berocen AeRAY AND LINKED Lut AReay Size OF an Array is Fieed Array) is @ collettton oF Homogeneous fo) Moiced List Ts a Collection of node Cstmilar) dara type (deta y addvess) Memory 1s atjocared From stauk Memory 1s allocates From heap y Fpriey work with starie dara UW) Makes Uist work wirr dynamic dara Sruuure. chrucure - Elemente are stored Yn Contiguous 6). Elements can be stored anyonere memory location tn the memory. Airrey elements ave fndependent to 6). Anied Wst elemenre are tepend to each omer each other a). Arvoy tole more time A): Marked - ct tale less Himes (insertion yf peterfon) (C Insevtton g peterfon’) Prue pomae Cuiseenies) WeWLLELELETUUTTTTIT IIIT 7 Tree Tree 1s 9 corleuton of nodes and Cages ex T= (node, 4ges? Thien 164 unique node called yoot In tree There Loltl not be any cycie/ Loops + Represents dara tn Ext form of 4 tree Struzuce laa hlerarentead manner. . Tn tree only one path beriveen Ho noses. In pus preorder, In order and preorder Traverse erie pruticomae ChinticeDia)) GRAPH 4): Graph tsa cotleuton oF vertices | nodes and edges ex G=AV,ey 2): There 1s no unique node B)- There can be loops/cytie. U)> Represents data clmfiax to 4 nerwerks 5) Tn GyaPn One oF more then one path burween p00 noder. Tn prfe BEL and DES traversal.

You might also like