SlideShare a Scribd company logo
1 of 16
DESIGN AND ANALYSIS PF
ALGORITHMS
UNIT-4
ABHIMANYU MISHRA
ASSISTANT PROF.(CSE)
JETGI
24/12/16 1Abhimanyu Mishra(CSE) JETGI
 Dynamic programming
 Warshal’s and floyd’s algorithm
 Resource allocation problem
 Backtracking
 Branch and bound
 Graph and colouring
 N-Queen problem
 Hamiltonian cycles
 Sum of subsets
CONTENTS
24/12/16 2Abhimanyu Mishra(CSE) JETGI
Dynamic programming is a technique for solving problem similar to divide
and conquer by dividing a problem into sub problems whose solutions may viewed as
the result of a sequence of decisions.
Dynamic programming is a bottom-up approach and it is used when sub
problems are not independent.
Dynamic programming solution to 0-1 knapsack problem:
0 if i=0,or w=0
c[i,w]= c[i-1,w] if wi>w
max{(c[i-1,w],vi+c[i-1,w-wi]) w>=wi
Dynamic programming
24/12/16 3Abhimanyu Mishra(CSE) JETGI
Cont…..
24/12/16 4Abhimanyu Mishra(CSE) JETGI
Dynamic 0-1 knapsack (v,w,n,w)
1. for w=0 to W
2. do c[0,w]=0
3. for i=1 to n
4. do c[i,0]=0
5. for w=1 to W
6. do if wi=<w
7. then if vi+c[i-1,w-wi]
8. then c[i,w]=vi+c[i-1,w-wi]
9. else c[i,w]=c[i-1,w]
10. else
11. c[i,w]=c[i-1,w]
24/12/16 5Abhimanyu Mishra(CSE) JETGI
Matrix-Chain Multiplication
1. n← length[p]-1
2. for i ← 1 to n
3. do m[i,i] ←0
4. for i ←2 to n
5. l is the chain length
6. do for i ←1 to n-1+1
7. do j ←i+1-1
8. m[i,j] ←∞
9. for k ←i to j-1
10. do q ←m[i,k]+m[k+1,j]+pi-1pkpj
11. if q<m[i,j]
12. then m[i,j] ←q
13. s[i,j] ←k
14. return m and s
Warshal’s and floyd’s algorithm
Floyd-Warshal algorithm is an algorithm which is used to find the shortest
paths among all the pairs of nodes in a graph, which does not contain any
cycles of negative length .The main advantage is its simplicity.
1. n  rows[w]
2. d  w
3. for k=1 to n
4. do for i  1 to n
5. do for j  1 to n
6. do for di
k  min (dij,dik
(k-1)+dkj
(K-1))
7. return Do
dij= wij if k=0
min[dij
(k-1),dik
(K-1)+dkj
(K-1)]
24/12/16 6Abhimanyu Mishra(CSE) JETGI
24/12/16 7Abhimanyu Mishra(CSE) JETGI
Do =
1
3
24
1 8
9 1
4 2
0 8 ∞ 1
∞ 0 1 ∞
4 ∞ 0 ∞
∞ 2 9 0
D1 =
0 8 ∞ 1
∞ 0 1 ∞
4 12 0 5
∞ 2 9 0
D2 =
0 8 9 1
∞ 0 1 ∞
4 12 0 5
∞ 2 3 0
D3 =
0 8 9 1
5 0 1 ∞
4 12 0 5
7 2 3 0
D4 =
0 3 4 1
5 0 1 ∞
4 7 0 5
7 2 3 0
24/12/16 8Abhimanyu Mishra(CSE) JETGI
∏0=
N 1 N 1
N N 2 N
4 N N N
N 4 4 N
∏1=
N 1 N 1
N N 2 N
3 1 N 1
N 4 4 N
∏2=
N 1 2 1
N N 2 N
3 1 N 1
N 4 2 N
∏3=
N 1 2 1
3 N 2 3
3 1 N 1
3 4 2 N
∏4=
N 4 4 1
3 N 2 3
3 4 N 1
3 4 2 N
24/12/16 9Abhimanyu Mishra(CSE) JETGI
Backtracking
Backtracking is a recursive process where we start with one possible move out of
many available moves and try to solve the problem if we are able to solve the problem with
The selected move then we will print the solution else we will backtrack and select some
Other move and try to solve it. If none if the moves work out we will claim that there is no
solution for the problem.
24/12/16 10Abhimanyu Mishra(CSE) JETGI
Branch and bound
It is also called as best-first search. Branch and bound is a systematic
method for solving optimization problems. When backtracking and greedy method
fails branch and bound is applied. In this process, we used to calculate the bound at
each stage and check whether it is able to give answer or not.
Graph and Coloring
24/12/16 11Abhimanyu Mishra(CSE) JETGI
Coloring all the vertices of a graph with colors such that no two adjacent
vertices have the same color is called as graph coloring.
24/12/16 12Abhimanyu Mishra(CSE) JETGI
In n-Queen problem, we have to place n-Queen in an n x n chessboard so that no
queen attack each other i.e., no two queen are placed on the same row, column or diagonal.
Place(k,i):
1. For j  1 to k-1
2. do if (x(j)=i) or abs(x[j]-i)=(abs(j-k))
3. Then return false
n-Queen(k,n):
1. for i  1 to n
2. do if place(k,i)
3. Then x[k]  i
4. if k=n, then print x[1…….N]
5. else n-Queen(k=1,n)
Suppose we have 4 queens i.e, q1,q2,q3,q4 Step1.
N-Queen problem
q1
24/12/16 13Abhimanyu Mishra(CSE) JETGI
Steps 2. q1
q2
Steps 3.
It is impossible for q4 to
placed in the 4
th
row since
the other queen attack the
4
th
queen so we use the
concept of backtracking.
Steps 4.
<2,4,1,3>
q1
q2
q3
q1
q2
q3
q4
24/12/16 14Abhimanyu Mishra(CSE) JETGI
Hamiltonian cycles
A Hamiltonian cycle is also known as Hamiltonian circuit. A
Hamiltonian cycle is a Hamiltonian Path such that there exit an edge in
graph from the last vertex to the first vertex of the Hamiltonian Path.
Whether the graph contains Hamiltonian Cycle or not. If it contains
Hamiltonian Cycle, then path is done.
For example, a Hamiltonian Cycle for the graph{0, 1, 2, 4, 3, 0}.
There are more Hamiltonian Cycles in the graph like {0, 3, 4, 2, 1, 0}
0 1 2
3 4
Sum of subsets
And the following graph doesn’t contain any Hamiltonian Cycle.
24/12/16 15Abhimanyu Mishra(CSE) JETGI
0 1 2
3 4
24/12/16 16Abhimanyu Mishra(CSE) JETGI
Sum of subsets
In this problem, we have to find the subset of the given set S where the elements in
the set are n positive interferes in such a manner that s` belongs to S and the sum of elements
of subset s` is equal to some positive integer X. The subset problem can be calculated

More Related Content

What's hot

UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithmRezwan Siam
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAsst.prof M.Gokilavani
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy AlgorithmWaqar Akram
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptarunsingh660
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gamemanika kumari
 
Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).munawerzareef
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfHarshNagda5
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 

What's hot (20)

UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Red black tree
Red black treeRed black tree
Red black tree
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
 
Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdf
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 

Similar to Daa unit 4

Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Abhimanyu Mishra
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!A Jorge Garcia
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cyclevarun arora
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfShiwani Gupta
 
Linear programming manzoor nabi
Linear programming  manzoor nabiLinear programming  manzoor nabi
Linear programming manzoor nabiManzoor Wani
 
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...IJERA Editor
 
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...IJERA Editor
 
November 3, 2014
November 3, 2014November 3, 2014
November 3, 2014khyps13
 
Matrix Completion Presentation
Matrix Completion PresentationMatrix Completion Presentation
Matrix Completion PresentationMichael Hankin
 
7 1solve By Graphing
7 1solve By Graphing7 1solve By Graphing
7 1solve By Graphingtaco40
 
Solving Linear Equations
Solving Linear EquationsSolving Linear Equations
Solving Linear Equationstaco40
 
Basic%20Cal%20Final.docx.docx
Basic%20Cal%20Final.docx.docxBasic%20Cal%20Final.docx.docx
Basic%20Cal%20Final.docx.docxSalwaAbdulkarim1
 
Foundation c2 exam august 2012 sols
Foundation c2 exam august 2012 solsFoundation c2 exam august 2012 sols
Foundation c2 exam august 2012 solsfatima d
 
Dynamic1
Dynamic1Dynamic1
Dynamic1MyAlome
 

Similar to Daa unit 4 (20)

Backtracking
BacktrackingBacktracking
Backtracking
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdf
 
maths 12th.pdf
maths 12th.pdfmaths 12th.pdf
maths 12th.pdf
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
Linear programming manzoor nabi
Linear programming  manzoor nabiLinear programming  manzoor nabi
Linear programming manzoor nabi
 
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
 
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...
 
November 3, 2014
November 3, 2014November 3, 2014
November 3, 2014
 
LINEAR FUNCTIONS
LINEAR FUNCTIONSLINEAR FUNCTIONS
LINEAR FUNCTIONS
 
Matrix Completion Presentation
Matrix Completion PresentationMatrix Completion Presentation
Matrix Completion Presentation
 
7 1solve By Graphing
7 1solve By Graphing7 1solve By Graphing
7 1solve By Graphing
 
Graphical method
Graphical methodGraphical method
Graphical method
 
Solving Linear Equations
Solving Linear EquationsSolving Linear Equations
Solving Linear Equations
 
Basic%20Cal%20Final.docx.docx
Basic%20Cal%20Final.docx.docxBasic%20Cal%20Final.docx.docx
Basic%20Cal%20Final.docx.docx
 
Foundation c2 exam august 2012 sols
Foundation c2 exam august 2012 solsFoundation c2 exam august 2012 sols
Foundation c2 exam august 2012 sols
 
Dynamic1
Dynamic1Dynamic1
Dynamic1
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
 

More from Abhimanyu Mishra

More from Abhimanyu Mishra (19)

Cd unit i
Cd unit iCd unit i
Cd unit i
 
Presentation1(JIT gnomio)
Presentation1(JIT gnomio)Presentation1(JIT gnomio)
Presentation1(JIT gnomio)
 
Sta unit 5(abimanyu)
Sta unit 5(abimanyu)Sta unit 5(abimanyu)
Sta unit 5(abimanyu)
 
Sta unit 3(abimanyu)
Sta unit 3(abimanyu)Sta unit 3(abimanyu)
Sta unit 3(abimanyu)
 
Sta unit 4(abimanyu)
Sta unit 4(abimanyu)Sta unit 4(abimanyu)
Sta unit 4(abimanyu)
 
Sta unit 3(abimanyu)
Sta unit 3(abimanyu)Sta unit 3(abimanyu)
Sta unit 3(abimanyu)
 
Sta unit 2(abimanyu)
Sta unit 2(abimanyu)Sta unit 2(abimanyu)
Sta unit 2(abimanyu)
 
Unit1
Unit1Unit1
Unit1
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Software Engineering unit 5
Software Engineering unit 5Software Engineering unit 5
Software Engineering unit 5
 
Software Engineering unit 4
Software Engineering unit 4Software Engineering unit 4
Software Engineering unit 4
 
Software Engineering unit 3
Software Engineering unit 3Software Engineering unit 3
Software Engineering unit 3
 
Software Engineering unit 2
Software Engineering unit 2Software Engineering unit 2
Software Engineering unit 2
 
Software Engineering Unit 1
Software Engineering Unit 1Software Engineering Unit 1
Software Engineering Unit 1
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5
 
Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4
 
Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 

Recently uploaded

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 

Recently uploaded (20)

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 

Daa unit 4

  • 1. DESIGN AND ANALYSIS PF ALGORITHMS UNIT-4 ABHIMANYU MISHRA ASSISTANT PROF.(CSE) JETGI 24/12/16 1Abhimanyu Mishra(CSE) JETGI
  • 2.  Dynamic programming  Warshal’s and floyd’s algorithm  Resource allocation problem  Backtracking  Branch and bound  Graph and colouring  N-Queen problem  Hamiltonian cycles  Sum of subsets CONTENTS 24/12/16 2Abhimanyu Mishra(CSE) JETGI
  • 3. Dynamic programming is a technique for solving problem similar to divide and conquer by dividing a problem into sub problems whose solutions may viewed as the result of a sequence of decisions. Dynamic programming is a bottom-up approach and it is used when sub problems are not independent. Dynamic programming solution to 0-1 knapsack problem: 0 if i=0,or w=0 c[i,w]= c[i-1,w] if wi>w max{(c[i-1,w],vi+c[i-1,w-wi]) w>=wi Dynamic programming 24/12/16 3Abhimanyu Mishra(CSE) JETGI
  • 4. Cont….. 24/12/16 4Abhimanyu Mishra(CSE) JETGI Dynamic 0-1 knapsack (v,w,n,w) 1. for w=0 to W 2. do c[0,w]=0 3. for i=1 to n 4. do c[i,0]=0 5. for w=1 to W 6. do if wi=<w 7. then if vi+c[i-1,w-wi] 8. then c[i,w]=vi+c[i-1,w-wi] 9. else c[i,w]=c[i-1,w] 10. else 11. c[i,w]=c[i-1,w]
  • 5. 24/12/16 5Abhimanyu Mishra(CSE) JETGI Matrix-Chain Multiplication 1. n← length[p]-1 2. for i ← 1 to n 3. do m[i,i] ←0 4. for i ←2 to n 5. l is the chain length 6. do for i ←1 to n-1+1 7. do j ←i+1-1 8. m[i,j] ←∞ 9. for k ←i to j-1 10. do q ←m[i,k]+m[k+1,j]+pi-1pkpj 11. if q<m[i,j] 12. then m[i,j] ←q 13. s[i,j] ←k 14. return m and s
  • 6. Warshal’s and floyd’s algorithm Floyd-Warshal algorithm is an algorithm which is used to find the shortest paths among all the pairs of nodes in a graph, which does not contain any cycles of negative length .The main advantage is its simplicity. 1. n  rows[w] 2. d  w 3. for k=1 to n 4. do for i  1 to n 5. do for j  1 to n 6. do for di k  min (dij,dik (k-1)+dkj (K-1)) 7. return Do dij= wij if k=0 min[dij (k-1),dik (K-1)+dkj (K-1)] 24/12/16 6Abhimanyu Mishra(CSE) JETGI
  • 7. 24/12/16 7Abhimanyu Mishra(CSE) JETGI Do = 1 3 24 1 8 9 1 4 2 0 8 ∞ 1 ∞ 0 1 ∞ 4 ∞ 0 ∞ ∞ 2 9 0 D1 = 0 8 ∞ 1 ∞ 0 1 ∞ 4 12 0 5 ∞ 2 9 0 D2 = 0 8 9 1 ∞ 0 1 ∞ 4 12 0 5 ∞ 2 3 0 D3 = 0 8 9 1 5 0 1 ∞ 4 12 0 5 7 2 3 0 D4 = 0 3 4 1 5 0 1 ∞ 4 7 0 5 7 2 3 0
  • 8. 24/12/16 8Abhimanyu Mishra(CSE) JETGI ∏0= N 1 N 1 N N 2 N 4 N N N N 4 4 N ∏1= N 1 N 1 N N 2 N 3 1 N 1 N 4 4 N ∏2= N 1 2 1 N N 2 N 3 1 N 1 N 4 2 N ∏3= N 1 2 1 3 N 2 3 3 1 N 1 3 4 2 N ∏4= N 4 4 1 3 N 2 3 3 4 N 1 3 4 2 N
  • 9. 24/12/16 9Abhimanyu Mishra(CSE) JETGI Backtracking Backtracking is a recursive process where we start with one possible move out of many available moves and try to solve the problem if we are able to solve the problem with The selected move then we will print the solution else we will backtrack and select some Other move and try to solve it. If none if the moves work out we will claim that there is no solution for the problem.
  • 10. 24/12/16 10Abhimanyu Mishra(CSE) JETGI Branch and bound It is also called as best-first search. Branch and bound is a systematic method for solving optimization problems. When backtracking and greedy method fails branch and bound is applied. In this process, we used to calculate the bound at each stage and check whether it is able to give answer or not.
  • 11. Graph and Coloring 24/12/16 11Abhimanyu Mishra(CSE) JETGI Coloring all the vertices of a graph with colors such that no two adjacent vertices have the same color is called as graph coloring.
  • 12. 24/12/16 12Abhimanyu Mishra(CSE) JETGI In n-Queen problem, we have to place n-Queen in an n x n chessboard so that no queen attack each other i.e., no two queen are placed on the same row, column or diagonal. Place(k,i): 1. For j  1 to k-1 2. do if (x(j)=i) or abs(x[j]-i)=(abs(j-k)) 3. Then return false n-Queen(k,n): 1. for i  1 to n 2. do if place(k,i) 3. Then x[k]  i 4. if k=n, then print x[1…….N] 5. else n-Queen(k=1,n) Suppose we have 4 queens i.e, q1,q2,q3,q4 Step1. N-Queen problem q1
  • 13. 24/12/16 13Abhimanyu Mishra(CSE) JETGI Steps 2. q1 q2 Steps 3. It is impossible for q4 to placed in the 4 th row since the other queen attack the 4 th queen so we use the concept of backtracking. Steps 4. <2,4,1,3> q1 q2 q3 q1 q2 q3 q4
  • 14. 24/12/16 14Abhimanyu Mishra(CSE) JETGI Hamiltonian cycles A Hamiltonian cycle is also known as Hamiltonian circuit. A Hamiltonian cycle is a Hamiltonian Path such that there exit an edge in graph from the last vertex to the first vertex of the Hamiltonian Path. Whether the graph contains Hamiltonian Cycle or not. If it contains Hamiltonian Cycle, then path is done. For example, a Hamiltonian Cycle for the graph{0, 1, 2, 4, 3, 0}. There are more Hamiltonian Cycles in the graph like {0, 3, 4, 2, 1, 0} 0 1 2 3 4
  • 15. Sum of subsets And the following graph doesn’t contain any Hamiltonian Cycle. 24/12/16 15Abhimanyu Mishra(CSE) JETGI 0 1 2 3 4
  • 16. 24/12/16 16Abhimanyu Mishra(CSE) JETGI Sum of subsets In this problem, we have to find the subset of the given set S where the elements in the set are n positive interferes in such a manner that s` belongs to S and the sum of elements of subset s` is equal to some positive integer X. The subset problem can be calculated