Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
33 views
12 pages
DAA Unit 2
Uploaded by
Sowmya Prajapathi
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
Download
Save
Save DAA Unit 2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
33 views
12 pages
DAA Unit 2
Uploaded by
Sowmya Prajapathi
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
Carousel Previous
Carousel Next
Download
Save
Save DAA Unit 2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save DAA Unit 2 For Later
You are on page 1
/ 12
Search
Fullscreen
Be SSloht Sets o- No Common elements on the eete © known as biefornt Sele, 40 So = ¢ DR fomt Set Set Opewatfons 2- These ave too opesations « They 27e # 4+ Sfimple Union a: Sfmple Fibd Onkon g * We Represent the Stinple Union f Tree data eleuctuse- + In all the elements , any one element 1% voot (or) parent elernent. exg S= G2, 3h s.= bast SUS, = Lasers} Procecduse 3 4+ Tnflfally consfdes all the elements treated as Sepavate toee a P(r} — pazent of node P. 3. Fou soot node Plf]=-1. qe OFter performing each Unfon Operation update pli]. Example ® 198 gS yy SS ait O © © @ © © Abelalalsle “Ue i-t{abufs sede da daysUnibo (142) Union (294) Unido (5,6) ® © @ © CombFhe (112) (254) Combine (1,3) (5,6) Union(1,3) Union (155) a (x @ oO Algoarthms Sfinple unfon (°,7) + Searching an element % the given set ¥e known as SFaple Find. =. TER a succesful seasch vetusns set representative Phemmes: elements: root /pasent Example Union (152) Search = 4 @ @ C) yee, % % successful Search because 4 % present i toes Tk setusne the Value 4.0 —— &« Algorithm ¢ Find (P) hele (P0120) PS pl?] 5 °°. vetusn P5 xarople g oO e pl 2 te bl es ea @ ) a = oD fod (4) faq P(i]z0 P(aJ=3 204% fea p(a]=1 20 Back Trackfog 2 Tt o . boule fotce approach ad kifog techniqye we use «In Back toacl Rg all posetble coluon wtih a lee, numbes means we vl of steps: fq back teackihg tech ofue, we Solve a pooblem th an «By using ZAnt way when Compared to other methods Itke greedy effi : method and clypamf proqvammiig.Example Take 3 Students 61, 82,G1 and avsange fh = chairs, (state Space toee) Genesal Method 3- * Tr thi technique we Seasch for cet of opltnal solutions which satiBfes some Constratdt: : * The back teack?og algerthm detesmthes the colutioo by systematically searching the Solution space for the qiven problem. Algor?thans Backtsack (mn) kst; wobtle (Kf) rr (these ase remaing an untied x (kJ e th G4, xf27,---- x(k-i]) and @, (x01 ,--.. xte]) % true) t fe (x1, —---x(] a path to answer node) waite (xt=K))5 Ko K+I; else K= KH; § 3LS lll Example 8 Take 3 students B81, B2) 4 bounding Funchian tha Bl (qr) stuctent Should be fo the mitdle of Boys (Bis Pr) we Use backtoack?ng and Fd all pos: 7 GSl should not be fo mtdle s (lala) Ba Gy : (erfen x Gu v Heve Bi Gy x Killed by bound: ° ocl¥oo ‘ 2 & & i Ss Here bounding function % tue, So Gn % i middle so back tzack. (tal x x Kélled by bounding Function, Se Heve, -B2) Gy ese bounding functin f tue , 50 back track (Go back) and areange fh 3 chats wrth a thes mt tn ot A A A A AD DD AY BD AD AD D-DD OD"Appltatioos a These axe @ types of opplicatfons: They ave 1. Queen's pzoblen 2. Sum Hy Subsete problern- 2+ Gzaph Coloring. N Queen's problem 2 + N Queen's problem & one of the Fportant application back tracking. + We colve WN Queen problem by toacking 4- Queens. + Consfdes 4x4 chess boasd and 4 Queens, The objective & to place 4 Queene t 4xq chess board stich that no too qpcens Should be placed Tf the Same Tow, Same Column, and tame dfagonal- Example 4x4 chess board o 1 ac .®: 2 {QiX|xK IK SHEE board (eI{c] EMENSNO OND GONG GS WW WOU el elle eA Y/Y YY UVStep ©% c=0, 7-0 check, board (o][o] = cafe Now Sesement columo by 4 Step oe cel, t2O0 check, board (0 |['] # Safe, because place Mh same Now fevement sow by a4 Step4.48 C=l, tel Check, boasd [1] (1] 4 Safe, because f places fh diagonal. Now fresement vous by 4 Step 4-2 3 C=l, 22 Check, board (2](t] = safe, because no qpteens fh rou 2 and column 4 Now fhesement column by 4 Step 2.0% c=2, 7-0 check; boavd (ol [2] # tafe, because already @,-% present: Now fievement vow by 4. Step 21% Co2,7=] Check , board [1] (2] # safe, because ft becomes diagonal for @.Q,: Now Thevement. rou by a Step 22200 C= 2) tea Check , board C2] (2 f cafe, because Pt bas alseady Qo: | a ahi hin ct i iil Now fresement sow by 4.Step BBS c=2, 753 check, beavd {a} C2] # Safe because *% becomes Afaqonal for Qs - Moar farvenenk colenencbye-d We seached last vow of column 2 , there % no safe postifon. we have to back track. Nokes ple bave ke semove last placed Queen the one == at posftion: b(2 TC] semoved new yous AtN=3 Column =1 2S Oo. o [a Be + @ 2, a 2 3 CAEAZ step 113 2 fle l,%=3 boasd C2] (J = safe fesement column by 4 (a Xe [x px Px De [> @ Qe Step ao% c=a,t=0 boavd (oJ [2] # safe: fresernent vou by 4 step ale C=Q, t=) : boasd [1] (2] = Safe Fheverment column by 4 Step. 310% C= 3) 7=O beard fo]{s] # safe thevement vow by 4Cw0CE_ Og ————__ LLU Step 3.12 c=, T=! board (1Jl2] # Safe Now fesement Tow by 4 rack, B28 C=], Ted board (2](s] # safe Now fresement row byt Step S32 cea, 023 board (s]fs] # safe $0) we veached the last column and last row. Do back track fag wermove last placed Queen boaed (1 J(2] % vermoved col=2 vow =I+1=2 et 2.3 Step-228 c=2, 722 ° fed |) | board (2](2] # Safe | New Freserment row by 4 > [ Xx 3 Q\K Step 213% C= 2) B23 board (3](2] ¢ safe we reached last vow and last Column. do backtrack?ng boasd [e]fo] % cemoved new set “Bou =| col =o (LLPP APLAR IBODAN An nnStep og C=0, 2-1 board (iT (oJ = cafe thevement columo by 4 Step 103 cal, %=0 board Co}(1] 7 safe Now fherement elim by 4 Step Wee C=Hljve) boasd (iJ {iJ # safe Now fhesement edlama by 4 step 28 CHlyver board [2 ]{i] = safe Novo Pacsement Column. by 1 Step a0 3 C=21350 boasd Co] [oJ = Safe Now fhesement column by 4 Step 30 2 C=3, %=0 board (o1(s] # safe- Now thesement row by 4 step a1 3 C= 3, P=) board {11(3] 4 safe Now frevemen{ vous by 4 step 323 C=3) Pe Ope 28 >. board (2T[s] =Safe 0 Qs Fihally we placed all 4 Queens, Q.{ Sure gf Subsets Problem 3 ‘ SSP Gh Subsets Roblem & eo a ° bk Sa S81)S29--Sp bi | The problem f to find a subset of & Tver SEE SE RSs Nn | a m % equal bo a gfven postlfve oO postive Thtegers whose su Ne Toteges Vd’. S28, ¢83~----- 5 Example @ Foo $= 113,454 and dae State Space Tsee % Baek. LashGeaph Colowtng * In Gpaph colosing problem we colo the vertices of graph fn sucha way that no two adjacent vesttes Shave the Same colour: 2 + To this problem woe have qfven a chromali nurnbes . th, whith Ts the least numbes of colours needed to color a graph. OP Ys mee \/ Red , Blue ,Gzeen- oO Blue Red OPN» as af Green Re: Example 3 (88, 4.G,R) State Space Trees
You might also like
Daa Unit-2final
PDF
No ratings yet
Daa Unit-2final
33 pages
Algorithms - CS3401 - Notes - Unit 4 - State Space Search Algorithms
PDF
No ratings yet
Algorithms - CS3401 - Notes - Unit 4 - State Space Search Algorithms
27 pages
Daa Backtracking
PDF
No ratings yet
Daa Backtracking
25 pages
Lec09 BacktrackingBranchBound
PDF
No ratings yet
Lec09 BacktrackingBranchBound
61 pages
Backtracking 1
PDF
No ratings yet
Backtracking 1
56 pages
Backtracking
PDF
No ratings yet
Backtracking
68 pages
DAA Unit4 Part2
PDF
No ratings yet
DAA Unit4 Part2
17 pages
Daa - Unit 5 Part 1
PDF
No ratings yet
Daa - Unit 5 Part 1
23 pages
8 Queen Problem
PDF
No ratings yet
8 Queen Problem
7 pages
Backtracking
PDF
No ratings yet
Backtracking
65 pages
Unit IV
PDF
No ratings yet
Unit IV
18 pages
Backtracking
PDF
No ratings yet
Backtracking
13 pages
Daa 4
PDF
No ratings yet
Daa 4
40 pages
DAA UNIT 5 Backtracking
PDF
No ratings yet
DAA UNIT 5 Backtracking
23 pages
DAA Unit-02
PDF
No ratings yet
DAA Unit-02
27 pages
Unit 5
PDF
No ratings yet
Unit 5
25 pages
ADA UNIT-3 Chapter-2 Backtracking
PDF
No ratings yet
ADA UNIT-3 Chapter-2 Backtracking
26 pages
Presentation 27616 Content Document 20241119113101AM
PDF
No ratings yet
Presentation 27616 Content Document 20241119113101AM
24 pages
Daa Unit-4
PDF
No ratings yet
Daa Unit-4
31 pages
Daaunit 4
PDF
No ratings yet
Daaunit 4
28 pages
Unit 2 Backtracking
PDF
No ratings yet
Unit 2 Backtracking
24 pages
Unit 4
PDF
No ratings yet
Unit 4
20 pages
Parse Tree
PDF
No ratings yet
Parse Tree
20 pages
Daa Unit-Iv
PDF
No ratings yet
Daa Unit-Iv
16 pages
Ada UNIT2
PDF
No ratings yet
Ada UNIT2
15 pages
DAA 4th
PDF
No ratings yet
DAA 4th
11 pages
Daa Unit-Iv
PDF
No ratings yet
Daa Unit-Iv
11 pages
Adobe Scan 10-Oct-2024
PDF
No ratings yet
Adobe Scan 10-Oct-2024
10 pages
AKJ11 Module4 (Complete
PDF
No ratings yet
AKJ11 Module4 (Complete
89 pages
Backtracking Programming
PDF
No ratings yet
Backtracking Programming
6 pages
DAA Unit-2.2
PDF
No ratings yet
DAA Unit-2.2
17 pages
DAA Unit 2 OBS
PDF
No ratings yet
DAA Unit 2 OBS
7 pages
Unit7 ADA SPPDF 2022 10 20 09 39 55pdf 2023 11 04 14 28 01
PDF
No ratings yet
Unit7 ADA SPPDF 2022 10 20 09 39 55pdf 2023 11 04 14 28 01
30 pages
Adsa - Unit-4-Mic 23
PDF
No ratings yet
Adsa - Unit-4-Mic 23
16 pages
Labassignment 1
PDF
No ratings yet
Labassignment 1
14 pages
A13 SESemIV AoA Experiment 9
PDF
No ratings yet
A13 SESemIV AoA Experiment 9
8 pages
Daa 5
PDF
No ratings yet
Daa 5
8 pages
Unit 4
PDF
No ratings yet
Unit 4
13 pages
Aoa Expt 9
PDF
No ratings yet
Aoa Expt 9
7 pages
6.1 N Queens Problem Using Backtracking - mp4
PDF
No ratings yet
6.1 N Queens Problem Using Backtracking - mp4
3 pages
Backtracking
PDF
No ratings yet
Backtracking
13 pages
Moduled 3 Backtracking
PDF
No ratings yet
Moduled 3 Backtracking
11 pages
DAA - Chapter - 5
PDF
No ratings yet
DAA - Chapter - 5
37 pages
Experiment No 5 AOA
PDF
No ratings yet
Experiment No 5 AOA
11 pages
Daa U2
PDF
No ratings yet
Daa U2
15 pages
Unit5 Daa
PDF
No ratings yet
Unit5 Daa
10 pages
Chapter 4 Backtracking Student
PDF
No ratings yet
Chapter 4 Backtracking Student
10 pages
Daa Unit 2
PDF
No ratings yet
Daa Unit 2
12 pages
LP III Assignment No 5
PDF
No ratings yet
LP III Assignment No 5
10 pages
Daa Unit Iii Backtracking and Branch and Bound
PDF
No ratings yet
Daa Unit Iii Backtracking and Branch and Bound
67 pages
DAA Unit 4
PDF
No ratings yet
DAA Unit 4
14 pages
18CS42 - Module-5
PDF
No ratings yet
18CS42 - Module-5
17 pages
Daa 250207 194917
PDF
No ratings yet
Daa 250207 194917
6 pages
Subsets, Graph Coloring, Hamiltonian Cycles, Knapsack Problem. Traveling Salesperson Problem
PDF
No ratings yet
Subsets, Graph Coloring, Hamiltonian Cycles, Knapsack Problem. Traveling Salesperson Problem
22 pages
DAA Unit 5
PDF
No ratings yet
DAA Unit 5
12 pages
Modified by Dr. ISSAM ALHADID 25/3/2019
PDF
No ratings yet
Modified by Dr. ISSAM ALHADID 25/3/2019
52 pages
COMP2230 Introduction To Algorithmics: A/Prof Ljiljana Brankovic
PDF
No ratings yet
COMP2230 Introduction To Algorithmics: A/Prof Ljiljana Brankovic
18 pages
Daa Notes Unit 4
PDF
No ratings yet
Daa Notes Unit 4
14 pages