SlideShare une entreprise Scribd logo
1  sur  65
DESIGN AND ANALYSIS OF ALGORITHMS Remember this: “No problem is too tough if u spend enuf time on it” 				-A great man Question: an+bn=cn   find a,b,c   Answer: Ethoingayirukku!! an+bn=cn   PRESENTED BY ARVIND KRISHNAA J
CONTENTS OF THE UNIT ,[object Object]
CONNECTED COMPONENTS
SPANNING TREES
BI-CONNECTED COMPONENTS
BRANCH AND BOUND:GENERAL METHODS(FIFO & LC)
0/1 KNAPSACK PROBLEM
INTRODUCTION TO NP-HARD AND NPCOMPLETENESSPRESENTED BY ARVIND KRISHNAA J UNIT –V SYLLABUS
AIM: The main aim of any graph traversal algorithm is for a given graph G=(V,E) is to determine whether there exists a path starting from a vertex v to a vertex u PRESENTED BY ARVIND KRISHNAA J GRAPH TRAVERSALS
PRESENTED BY ARVIND KRISHNAA J GRAPH TRAVERSALS
PRESENTED BY ARVIND KRISHNAA J BREADTH FIRST SEARCH BASIC IDEA: Visits graph vertices by moving across to all the neighbors of last visited vertex b  BFS uses a queue a vertex is inserted into queue when it is reached for the first time, and is marked as visited. a vertex is removed from the queue, when it identifies all unvisited vertices that are adjacent to the vertex b
PRESENTED BY ARVIND KRISHNAA J ALGORITHM FOR BFS void BFS(int v) { //v being a starting vertex int u=v; Queue q[SIZE]; visited[v]=1; do { for all vertices w adjacent to to u { 	if(visited[w]==0)//w is unvisited 	{ q.AddQ(w); visited[w]=1; 	} } if(Q.Empty())	return; q.Delete(u); }while(1); }
PRESENTED BY ARVIND KRISHNAA J AN EXAMPLE GRAPH 1 2 3 6 4 5 7 8
PRESENTED BY ARVIND KRISHNAA J PERFORMING THE BREADTH FIRST TRAVERSAL void BFT(graph G,int n) { int i; boolean visited[SIZE]; for(i=1;i<=n;i++) visited[i]=0; for(i=1;i<=n;i++) if(!visited[i]) 	BFS[i}; }
PRESENTED BY ARVIND KRISHNAA J DEPTH FIRST SEARCH BASIC IDEA Starting vertex is arbitrarily chosen or determined by the problem. Visits graph’s vertices by always moving away from last visited vertex to unvisited one, backtracks if no adjacent unvisited vertex is available. Uses a stack a vertex is pushed onto the stack when it’s reached for the first time a vertex is popped off the stack when it becomes a dead end, i.e., when there is no adjacent unvisited vertex
PRESENTED BY ARVIND KRISHNAA J ALGORITHM FOR DFS void DFS(int v) { visited[v]=1; for each vertex w adjacent to v 	{ 	if(!visited[w]) 		DFS[w]; } }
PRESENTED BY ARVIND KRISHNAA J for the graph..... A B D E C
PRESENTED BY ARVIND KRISHNAA J APPLICATIONS BREADTH FIRST SEARCH: Greedy graph algorithms finding the minimum spanning tree using PRIM’S ALGORITHM single source (or) all pair shortest path using DIJKSTRA’S ALGORITHM NETWORK FLOW PROBLEM Testing for connected components DEPTH FIRST SEARCH: Testing for biconnected components(bi-connectivity) for eg., checking for the connectivity of a network
PRESENTED BY ARVIND KRISHNAA J CONNECTED COMPONENTS DEFINITION: Two vertices in a graph are in the same connected component if and only if there is a path from one vertex to the other NOTE: BFS algorithm can be used to test whether a graph is connected or not ,[object Object]
The number of calls made to the BFT function can be used to roughly determine the number of “disconnected” components,[object Object]
PRESENTED BY ARVIND KRISHNAA J FOR THE DIRECTED GRAPH A B C E D F
PRESENTED BY ARVIND KRISHNAA J THE DFS LIST IS E LIST MADE IN THE FIRST CALL LIST MADE DURING THE SECOND CALL As the number of calls made to the function is 2 it means that the graph is not connected There are two sets of connected components represented above
PRESENTED BY ARVIND KRISHNAA J SPANNING TREE BFS SPANNING TREE 1 BFS SPANNING TREE: A spanning tree constructed by performing the Breadth first search of a graph 2 3 6 4 5 7 8
PRESENTED BY ARVIND KRISHNAA J SPANNING TREE DFS SPANNING TREE 1 DFS SPANNING TREE: A spanning tree constructed by performing the Depth first search of a graph 2 3 6 4 5 7 8
PRESENTED BY ARVIND KRISHNAA J BICONNECTED COMPONENTS NOTE: Henceforth the word “Graph” would be used instead of the term “undirected Graph” ARTICULATION POINT: A vertex v in a connected graph is said to be an articulation point if and only if the the deletion of the vertex v and all its edges incident to it “disconnects” the graph into two or more non-empty components. Biconnected graph: A graph G is said to be biconnected if and only if it contains no articulation points Let us see an example....
PRESENTED BY ARVIND KRISHNAA J A connected graph 1 5 6 2 4 7 The articulation points are highlighted...removing them causes disconnection 8 3 10 9
PRESENTED BY ARVIND KRISHNAA J POINTS TO NOTE	 LEMMA: Two biconnected components can have at most one vertex in common and this vertex is an articulation point. TRANSLATION: The common vertex of two biconnected components is an articulation point. NOTE: No edge can be in two different biconnected components as this would require two common vertices(violation of Lemma!!)
PRESENTED BY ARVIND KRISHNAA J MAKING A CONNECTED GRAPH BICONNECTED TECHNIQUE: Simply add “redundant” edges between the connected components that have the articulation point (say a) in common... for example the previously discussed connected graph can be made biconnected by adding the throbbing links(see next slide...if u r asleep pls continue...)
PRESENTED BY ARVIND KRISHNAA J Connected to biconnected... 1 5 6 2 4 7 The articulation points are highlighted...removing them causes disconnection 8 3 10 9
PRESENTED BY ARVIND KRISHNAA J SCHEME TO CONSTRUCT A BICONNECTED COMPONENT for each articulation point a { let B1,B2,…Bk be the biconnected  components containing vertex a; 	let vi,vi≠a, be a vertex in Bi  , 				1≤i≤k; add to G the edges (vi,vi+1), 1≤i≤k; }  
SIMPLE ALGORITHM: Construct a DFS spanning tree for the given graph Have parameters dfn[u],L[u] Do a preorder traversal of the spanning tree and compute dfn[u] for each node as the ith node that is visited Compute the value of L[u] as PRESENTED BY ARVIND KRISHNAA J IDENTIFYING ARTICULATION POINTS L[u]=min{ dfn[u],min{L[w]|w is a child of u}, min{ dfn[w]  | (u,w) is a back edge}
SIMPLE ALGORITHM: Nodes which satisfy  L[w]≥dfn[u], w being the children of u are identified as articulation points SPECIAL CASE OF ROOT NODE Note: The root node is always listed as an articulation point if root node has exactly one child then exclude the root node from AP list else root node is also an articulation point PRESENTED BY ARVIND KRISHNAA J IDENTIFYING ARTICULATION POINTS contd...
PRESENTED BY ARVIND KRISHNAA J COMPUTATIONS FOR THE GIVEN GRAPH
Oh MahaZeeya..Oh MahaZeeya..NakkaMukkaNakka...Oh Shakalakka..Oh Randakka..(x2)Oh Laahi Oh Laahi..AyakaYahiYahi..Me Hoo..Me Hoo...DailamoDailamo..RahtullaSonali Oh..Oh MahaZeeya..Oh MahaZeeya..NakkaMukkaNakka...Oh Shakalakka..Oh Randakka..Samba Sambale..OsoseSayoSayo..HasiliFisili..Ilahi..YappaJippa..(x2) blah blahblablabla....... PRESENTED BY ARVIND KRISHNAA J RECAP OF YESTERDAY
Branch & Bound
Review of Backtracking	 1.  Construct the state-space tree • nodes: partial solutions • edges: choices in extending partial solutions 2. Explore the state space tree using depth-first search 3. “Prune” nonpromising nodes • dfs stops exploring subtrees rooted at nodes that cannot lead to a solution and backtracks to such a node’s parent to continue the search
Branch-and-Bound ,[object Object]
Applicable to optimization problems
Breadth first search(FIFO B&B) or D-search(LIFO B&B) is performed on the state space tree
For each node (partial solution) of a state-space tree, computes a bound on the value of the objective function for all descendants  of the node (extensions of the partial solution)
Uses the bound for:
ruling out certain nodes as “nonpromising” to prune the tree – if a node’s bound is not better than the best solution seen so far
guiding the search through state-space,[object Object]
 the sum is minimizedExample Job1Job2Job3Job4          Person a	     9	     2	     7	    8          Person b 	     6	     4	     3	    7          Person c	     5	     8	     1	    8          Person d	     7	     6	     9	    4 Lower bound: Any solution to this problem will have total cost                         at least: 2 + 3 + 1 + 4 (or 5 + 2 + 1 + 4)‏ N people n jobs cost should be small.
Example: First two levels of the state-space tree
Explanation Select 1st element from first row i.e9 Select minimum from remaining rows 3, 1, 4 not from 1st column So 9+3+1+4 = 17. Select 2nd element from first row i.e2 Select minimum from remaining rows 3, 1, 4 not from 2nd column So 2+3+1+4 = 10. Select 3rd element from first row i.e7 Select minimum from remaining rows 3, 1, 4 not from 3rd column So 7+4+5+4 = 20. Last one it is 8+3+1+6 = 18
Example (cont.)‏
Explanation(contd...) 1. Select 2nd element from first row i.e 2 Select 1st element from second row i.e 6 Select minimum from remaining rows 1, 4 not from 1st column So 2+6+1+4 = 13. 2. Select 2nd element from first row i.e 2 Cannot Select 2nd element from second row  3. Select 2nd element from first row i.e 2 Select 3rd element from third row i.e 3 Select minimum from remaining rows 5, 4 not from 3rd column So 2+3+5+4 = 14. 4. 2 + 7 + 1+7 =17 Note: Promising node is live node a->2 is live node.
Example: Complete state-space tree
0/1 KNAPSACK PROBLEM
Branch and bound Applicable to optimization problem The state space tree is generated using best first rule. PRESENTED BY ARVIND KRISHNAA J COMPARISON OF B&B AND BACKTRACKING Backtracking ,[object Object]
The state space tree is generated using DFS,[object Object]
Branch and Bound Scheme for Knapsack Problem Step 1: Order the items in decreasing order of relative values:  v1/w1… vn/wn Step 2: For a given integer parameter k, 0 ≤ k ≤ n, generate allsubsets of k items or less and for each of those that fit the knapsack, add the remaining items in decreasingorder of their value to weight ratios Step 3: Find the most valuable subset among the subsets generated in Step 2 and return it as the algorithm’s output
bound (maximum potential value) = currentValue + value of remaining objects fully placed + (K - totalSize) * (value density of item that is partially placed)   PRESENTED BY ARVIND KRISHNAA J SOME THINGS TO NOTE totalSize = currentSize + size of remaining objects that can be fully placed
k-1 bound = currentValue+∑ vj	+ (K - totalSize) * (vk/sk) j=i+1 For the root node, currentSize = 0,  currentValue = 0 PRESENTED BY ARVIND KRISHNAA J IN FORMULAE k-1 totalSize = currentSize + ∑ sj j=i+1
PRESENTED BY ARVIND KRISHNAA J THE STATE-SPACE TREE(WITH BOUND)[PERFORMING A BFS TRAVERSAL] HENCE THE FINAL ANWER SET WOULD BE X={1,0,1,0} i.e., objects 1 and 3 are chosen...2 and 4 are discarded
WHAT THE PREVIOUS PROBLEM DID Step 1: We will construct the state space where each node contains the total current value in the knapsack, the total current size of the contents of the knapsack, and maximum potential value that the knapsack can hold.  In the algorithm, we will also keep a record of the maximum value of any node (partially or completely filled knapsack) found so far. Step 2: Perform the breadth first traversal of the state space tree computing the bound and totalsize Step 3: Discard(prune)those “non-promising nodes” which either have (a) a lower bound than the other nodes at same level 		(b) whose size exceeds the total knapsack capacity Step 4: The above method involving the BFS of the state space tree is called  FIFO BRANCH & BOUND ALGORITHM
LC ALGORITHM(LEAST COST) ,[object Object]
In LC algorithm a traversal is performed on the state space tree
Each node is given a rank based on a minimization rule(also known as best first rule) f(x)(in case of the Knapsack problem the minimization rule can be stated as f(x)=--g(x),where g(x) is the maximization rule for the Knapsack problem) ,[object Object]
Repeat till a feasible solution is obtained(sorry i cant go into too much further detail....its getting too mathematical...)
Introduction NP-Hard AND NP-Completeness
Polynomial Time: Algorithms whose solution is found in polynomial time eg., Sorting, searching etc., Non-polynomial Time: Algorithms which DO NOT take polynomial time to find the solution eg., Travelling salesperson problem (O(n22n))   PRESENTED BY ARVIND KRISHNAA J TWO KINDS OF ALGORITHMS
Problems for which there is no polynomial time complexity, are computationally related There are two classes of such problems 1. NP  HARD AND  2. NP  COMPLETE PRESENTED BY ARVIND KRISHNAA J TWO KINDS OF ALGORITHMS
The problem that is NP complete has the property that it can be solved in polynomial time if and only if all the other NP complete problems can be solved in polynomial time PRESENTED BY ARVIND KRISHNAA J NP  COMPLETE

Contenu connexe

Tendances

Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Brute force-algorithm
Brute force-algorithmBrute force-algorithm
Brute force-algorithm9854098540
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesFellowBuddy.com
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListManishPrajapati78
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Depth first search and breadth first searching
Depth first search and breadth first searchingDepth first search and breadth first searching
Depth first search and breadth first searchingKawsar Hamid Sumon
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsMohamed Loey
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentationAlizay Khan
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AIvikas dhakane
 

Tendances (20)

Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Brute force-algorithm
Brute force-algorithmBrute force-algorithm
Brute force-algorithm
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Recursion
RecursionRecursion
Recursion
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Depth first search and breadth first searching
Depth first search and breadth first searchingDepth first search and breadth first searching
Depth first search and breadth first searching
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AI
 

En vedette

Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)Shanawaz Ahamed
 
Algorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesAlgorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesKumar Avinash
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure Ankit Kumar Singh
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first searchHossain Md Shakhawat
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms masterHossam Hassan
 
Hillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionHillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionMohamed Gad
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchchandsek666
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Searchbutest
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and GraphsIntro C# Book
 

En vedette (17)

Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
Algorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesAlgorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class Notes
 
Application of dfs
Application of dfsApplication of dfs
Application of dfs
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
 
Hillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionHillclimbing search algorthim #introduction
Hillclimbing search algorthim #introduction
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
130210107039 2130702
130210107039 2130702130210107039 2130702
130210107039 2130702
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Search
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
 

Similaire à Algorithms and Graph Traversal Techniques

graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxwhittemorelucilla
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...KUSHDHIRRA2111026030
 
Review session2
Review session2Review session2
Review session2NEEDY12345
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxarifimad15
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHSukhdeep Bisht
 
Cs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer keyCs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer keyappasami
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilersComputer Science Club
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data StructureProf Ansari
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structuresSavit Chandra
 
A Tutorial on Computational Geometry
A Tutorial on Computational GeometryA Tutorial on Computational Geometry
A Tutorial on Computational GeometryMinh-Tri Pham
 
Link Prediction in the Real World
Link Prediction in the Real WorldLink Prediction in the Real World
Link Prediction in the Real WorldBalaji Ganesan
 

Similaire à Algorithms and Graph Traversal Techniques (20)

graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
 
Graphs
GraphsGraphs
Graphs
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
Review session2
Review session2Review session2
Review session2
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
 
Graphs
GraphsGraphs
Graphs
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGH
 
Cs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer keyCs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer key
 
Dijkstra
DijkstraDijkstra
Dijkstra
 
d
dd
d
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data Structure
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Graps 2
Graps 2Graps 2
Graps 2
 
A Tutorial on Computational Geometry
A Tutorial on Computational GeometryA Tutorial on Computational Geometry
A Tutorial on Computational Geometry
 
Link Prediction in the Real World
Link Prediction in the Real WorldLink Prediction in the Real World
Link Prediction in the Real World
 

Plus de Arvind Krishnaa

Twitter Agreement Analysis
Twitter Agreement AnalysisTwitter Agreement Analysis
Twitter Agreement AnalysisArvind Krishnaa
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesArvind Krishnaa
 
Human Altruism and Cooperation
Human Altruism and CooperationHuman Altruism and Cooperation
Human Altruism and CooperationArvind Krishnaa
 
Final review presentation
Final review presentationFinal review presentation
Final review presentationArvind Krishnaa
 
Third review presentation
Third review presentationThird review presentation
Third review presentationArvind Krishnaa
 
Second review presentation
Second review presentationSecond review presentation
Second review presentationArvind Krishnaa
 
First review presentation
First review presentationFirst review presentation
First review presentationArvind Krishnaa
 
Zeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCZeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCArvind Krishnaa
 
Canvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewCanvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewArvind Krishnaa
 
Canvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewCanvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewArvind Krishnaa
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesArvind Krishnaa
 
Smart camera monitoring system
Smart camera monitoring systemSmart camera monitoring system
Smart camera monitoring systemArvind Krishnaa
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot ProcessArvind Krishnaa
 

Plus de Arvind Krishnaa (18)

Twitter Agreement Analysis
Twitter Agreement AnalysisTwitter Agreement Analysis
Twitter Agreement Analysis
 
Analogical thinking
Analogical thinkingAnalogical thinking
Analogical thinking
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequences
 
Human Altruism and Cooperation
Human Altruism and CooperationHuman Altruism and Cooperation
Human Altruism and Cooperation
 
Chowka bhara
Chowka bharaChowka bhara
Chowka bhara
 
Canscape
CanscapeCanscape
Canscape
 
Final review presentation
Final review presentationFinal review presentation
Final review presentation
 
Third review presentation
Third review presentationThird review presentation
Third review presentation
 
Second review presentation
Second review presentationSecond review presentation
Second review presentation
 
First review presentation
First review presentationFirst review presentation
First review presentation
 
Zeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCZeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMC
 
Canvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewCanvas Based Presentation tool - First Review
Canvas Based Presentation tool - First Review
 
Canvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewCanvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth Review
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View Classes
 
Smart camera monitoring system
Smart camera monitoring systemSmart camera monitoring system
Smart camera monitoring system
 
Marine Pollution
Marine PollutionMarine Pollution
Marine Pollution
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot Process
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 

Dernier

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 

Dernier (20)

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 

Algorithms and Graph Traversal Techniques

  • 1. DESIGN AND ANALYSIS OF ALGORITHMS Remember this: “No problem is too tough if u spend enuf time on it” -A great man Question: an+bn=cn find a,b,c   Answer: Ethoingayirukku!! an+bn=cn   PRESENTED BY ARVIND KRISHNAA J
  • 2.
  • 6. BRANCH AND BOUND:GENERAL METHODS(FIFO & LC)
  • 8. INTRODUCTION TO NP-HARD AND NPCOMPLETENESSPRESENTED BY ARVIND KRISHNAA J UNIT –V SYLLABUS
  • 9. AIM: The main aim of any graph traversal algorithm is for a given graph G=(V,E) is to determine whether there exists a path starting from a vertex v to a vertex u PRESENTED BY ARVIND KRISHNAA J GRAPH TRAVERSALS
  • 10. PRESENTED BY ARVIND KRISHNAA J GRAPH TRAVERSALS
  • 11. PRESENTED BY ARVIND KRISHNAA J BREADTH FIRST SEARCH BASIC IDEA: Visits graph vertices by moving across to all the neighbors of last visited vertex b BFS uses a queue a vertex is inserted into queue when it is reached for the first time, and is marked as visited. a vertex is removed from the queue, when it identifies all unvisited vertices that are adjacent to the vertex b
  • 12. PRESENTED BY ARVIND KRISHNAA J ALGORITHM FOR BFS void BFS(int v) { //v being a starting vertex int u=v; Queue q[SIZE]; visited[v]=1; do { for all vertices w adjacent to to u { if(visited[w]==0)//w is unvisited { q.AddQ(w); visited[w]=1; } } if(Q.Empty()) return; q.Delete(u); }while(1); }
  • 13. PRESENTED BY ARVIND KRISHNAA J AN EXAMPLE GRAPH 1 2 3 6 4 5 7 8
  • 14. PRESENTED BY ARVIND KRISHNAA J PERFORMING THE BREADTH FIRST TRAVERSAL void BFT(graph G,int n) { int i; boolean visited[SIZE]; for(i=1;i<=n;i++) visited[i]=0; for(i=1;i<=n;i++) if(!visited[i]) BFS[i}; }
  • 15. PRESENTED BY ARVIND KRISHNAA J DEPTH FIRST SEARCH BASIC IDEA Starting vertex is arbitrarily chosen or determined by the problem. Visits graph’s vertices by always moving away from last visited vertex to unvisited one, backtracks if no adjacent unvisited vertex is available. Uses a stack a vertex is pushed onto the stack when it’s reached for the first time a vertex is popped off the stack when it becomes a dead end, i.e., when there is no adjacent unvisited vertex
  • 16. PRESENTED BY ARVIND KRISHNAA J ALGORITHM FOR DFS void DFS(int v) { visited[v]=1; for each vertex w adjacent to v { if(!visited[w]) DFS[w]; } }
  • 17. PRESENTED BY ARVIND KRISHNAA J for the graph..... A B D E C
  • 18. PRESENTED BY ARVIND KRISHNAA J APPLICATIONS BREADTH FIRST SEARCH: Greedy graph algorithms finding the minimum spanning tree using PRIM’S ALGORITHM single source (or) all pair shortest path using DIJKSTRA’S ALGORITHM NETWORK FLOW PROBLEM Testing for connected components DEPTH FIRST SEARCH: Testing for biconnected components(bi-connectivity) for eg., checking for the connectivity of a network
  • 19.
  • 20.
  • 21. PRESENTED BY ARVIND KRISHNAA J FOR THE DIRECTED GRAPH A B C E D F
  • 22. PRESENTED BY ARVIND KRISHNAA J THE DFS LIST IS E LIST MADE IN THE FIRST CALL LIST MADE DURING THE SECOND CALL As the number of calls made to the function is 2 it means that the graph is not connected There are two sets of connected components represented above
  • 23. PRESENTED BY ARVIND KRISHNAA J SPANNING TREE BFS SPANNING TREE 1 BFS SPANNING TREE: A spanning tree constructed by performing the Breadth first search of a graph 2 3 6 4 5 7 8
  • 24. PRESENTED BY ARVIND KRISHNAA J SPANNING TREE DFS SPANNING TREE 1 DFS SPANNING TREE: A spanning tree constructed by performing the Depth first search of a graph 2 3 6 4 5 7 8
  • 25. PRESENTED BY ARVIND KRISHNAA J BICONNECTED COMPONENTS NOTE: Henceforth the word “Graph” would be used instead of the term “undirected Graph” ARTICULATION POINT: A vertex v in a connected graph is said to be an articulation point if and only if the the deletion of the vertex v and all its edges incident to it “disconnects” the graph into two or more non-empty components. Biconnected graph: A graph G is said to be biconnected if and only if it contains no articulation points Let us see an example....
  • 26. PRESENTED BY ARVIND KRISHNAA J A connected graph 1 5 6 2 4 7 The articulation points are highlighted...removing them causes disconnection 8 3 10 9
  • 27. PRESENTED BY ARVIND KRISHNAA J POINTS TO NOTE LEMMA: Two biconnected components can have at most one vertex in common and this vertex is an articulation point. TRANSLATION: The common vertex of two biconnected components is an articulation point. NOTE: No edge can be in two different biconnected components as this would require two common vertices(violation of Lemma!!)
  • 28. PRESENTED BY ARVIND KRISHNAA J MAKING A CONNECTED GRAPH BICONNECTED TECHNIQUE: Simply add “redundant” edges between the connected components that have the articulation point (say a) in common... for example the previously discussed connected graph can be made biconnected by adding the throbbing links(see next slide...if u r asleep pls continue...)
  • 29. PRESENTED BY ARVIND KRISHNAA J Connected to biconnected... 1 5 6 2 4 7 The articulation points are highlighted...removing them causes disconnection 8 3 10 9
  • 30. PRESENTED BY ARVIND KRISHNAA J SCHEME TO CONSTRUCT A BICONNECTED COMPONENT for each articulation point a { let B1,B2,…Bk be the biconnected components containing vertex a; let vi,vi≠a, be a vertex in Bi  , 1≤i≤k; add to G the edges (vi,vi+1), 1≤i≤k; }  
  • 31. SIMPLE ALGORITHM: Construct a DFS spanning tree for the given graph Have parameters dfn[u],L[u] Do a preorder traversal of the spanning tree and compute dfn[u] for each node as the ith node that is visited Compute the value of L[u] as PRESENTED BY ARVIND KRISHNAA J IDENTIFYING ARTICULATION POINTS L[u]=min{ dfn[u],min{L[w]|w is a child of u}, min{ dfn[w] | (u,w) is a back edge}
  • 32. SIMPLE ALGORITHM: Nodes which satisfy L[w]≥dfn[u], w being the children of u are identified as articulation points SPECIAL CASE OF ROOT NODE Note: The root node is always listed as an articulation point if root node has exactly one child then exclude the root node from AP list else root node is also an articulation point PRESENTED BY ARVIND KRISHNAA J IDENTIFYING ARTICULATION POINTS contd...
  • 33. PRESENTED BY ARVIND KRISHNAA J COMPUTATIONS FOR THE GIVEN GRAPH
  • 34. Oh MahaZeeya..Oh MahaZeeya..NakkaMukkaNakka...Oh Shakalakka..Oh Randakka..(x2)Oh Laahi Oh Laahi..AyakaYahiYahi..Me Hoo..Me Hoo...DailamoDailamo..RahtullaSonali Oh..Oh MahaZeeya..Oh MahaZeeya..NakkaMukkaNakka...Oh Shakalakka..Oh Randakka..Samba Sambale..OsoseSayoSayo..HasiliFisili..Ilahi..YappaJippa..(x2) blah blahblablabla....... PRESENTED BY ARVIND KRISHNAA J RECAP OF YESTERDAY
  • 36. Review of Backtracking 1. Construct the state-space tree • nodes: partial solutions • edges: choices in extending partial solutions 2. Explore the state space tree using depth-first search 3. “Prune” nonpromising nodes • dfs stops exploring subtrees rooted at nodes that cannot lead to a solution and backtracks to such a node’s parent to continue the search
  • 37.
  • 39. Breadth first search(FIFO B&B) or D-search(LIFO B&B) is performed on the state space tree
  • 40. For each node (partial solution) of a state-space tree, computes a bound on the value of the objective function for all descendants of the node (extensions of the partial solution)
  • 42. ruling out certain nodes as “nonpromising” to prune the tree – if a node’s bound is not better than the best solution seen so far
  • 43.
  • 44. the sum is minimizedExample Job1Job2Job3Job4 Person a 9 2 7 8 Person b 6 4 3 7 Person c 5 8 1 8 Person d 7 6 9 4 Lower bound: Any solution to this problem will have total cost at least: 2 + 3 + 1 + 4 (or 5 + 2 + 1 + 4)‏ N people n jobs cost should be small.
  • 45. Example: First two levels of the state-space tree
  • 46. Explanation Select 1st element from first row i.e9 Select minimum from remaining rows 3, 1, 4 not from 1st column So 9+3+1+4 = 17. Select 2nd element from first row i.e2 Select minimum from remaining rows 3, 1, 4 not from 2nd column So 2+3+1+4 = 10. Select 3rd element from first row i.e7 Select minimum from remaining rows 3, 1, 4 not from 3rd column So 7+4+5+4 = 20. Last one it is 8+3+1+6 = 18
  • 48. Explanation(contd...) 1. Select 2nd element from first row i.e 2 Select 1st element from second row i.e 6 Select minimum from remaining rows 1, 4 not from 1st column So 2+6+1+4 = 13. 2. Select 2nd element from first row i.e 2 Cannot Select 2nd element from second row 3. Select 2nd element from first row i.e 2 Select 3rd element from third row i.e 3 Select minimum from remaining rows 5, 4 not from 3rd column So 2+3+5+4 = 14. 4. 2 + 7 + 1+7 =17 Note: Promising node is live node a->2 is live node.
  • 51.
  • 52.
  • 53. Branch and Bound Scheme for Knapsack Problem Step 1: Order the items in decreasing order of relative values: v1/w1… vn/wn Step 2: For a given integer parameter k, 0 ≤ k ≤ n, generate allsubsets of k items or less and for each of those that fit the knapsack, add the remaining items in decreasingorder of their value to weight ratios Step 3: Find the most valuable subset among the subsets generated in Step 2 and return it as the algorithm’s output
  • 54. bound (maximum potential value) = currentValue + value of remaining objects fully placed + (K - totalSize) * (value density of item that is partially placed)   PRESENTED BY ARVIND KRISHNAA J SOME THINGS TO NOTE totalSize = currentSize + size of remaining objects that can be fully placed
  • 55. k-1 bound = currentValue+∑ vj + (K - totalSize) * (vk/sk) j=i+1 For the root node, currentSize = 0, currentValue = 0 PRESENTED BY ARVIND KRISHNAA J IN FORMULAE k-1 totalSize = currentSize + ∑ sj j=i+1
  • 56. PRESENTED BY ARVIND KRISHNAA J THE STATE-SPACE TREE(WITH BOUND)[PERFORMING A BFS TRAVERSAL] HENCE THE FINAL ANWER SET WOULD BE X={1,0,1,0} i.e., objects 1 and 3 are chosen...2 and 4 are discarded
  • 57. WHAT THE PREVIOUS PROBLEM DID Step 1: We will construct the state space where each node contains the total current value in the knapsack, the total current size of the contents of the knapsack, and maximum potential value that the knapsack can hold. In the algorithm, we will also keep a record of the maximum value of any node (partially or completely filled knapsack) found so far. Step 2: Perform the breadth first traversal of the state space tree computing the bound and totalsize Step 3: Discard(prune)those “non-promising nodes” which either have (a) a lower bound than the other nodes at same level (b) whose size exceeds the total knapsack capacity Step 4: The above method involving the BFS of the state space tree is called FIFO BRANCH & BOUND ALGORITHM
  • 58.
  • 59. In LC algorithm a traversal is performed on the state space tree
  • 60.
  • 61. Repeat till a feasible solution is obtained(sorry i cant go into too much further detail....its getting too mathematical...)
  • 62. Introduction NP-Hard AND NP-Completeness
  • 63. Polynomial Time: Algorithms whose solution is found in polynomial time eg., Sorting, searching etc., Non-polynomial Time: Algorithms which DO NOT take polynomial time to find the solution eg., Travelling salesperson problem (O(n22n))   PRESENTED BY ARVIND KRISHNAA J TWO KINDS OF ALGORITHMS
  • 64. Problems for which there is no polynomial time complexity, are computationally related There are two classes of such problems 1. NP HARD AND 2. NP COMPLETE PRESENTED BY ARVIND KRISHNAA J TWO KINDS OF ALGORITHMS
  • 65. The problem that is NP complete has the property that it can be solved in polynomial time if and only if all the other NP complete problems can be solved in polynomial time PRESENTED BY ARVIND KRISHNAA J NP COMPLETE
  • 66. If an NP-hard problem can be solved in ploynomial time, then all NP complete problems can also be solved in polynomial time. PRESENTED BY ARVIND KRISHNAA J NP HARD
  • 67. PRESENTED BY ARVIND KRISHNAA J SET REPRESENTATION OF THE ABOVE STATEMENTS NP NP HARD P NP COMPLETE
  • 68. Deterministic Algorithm: Has the property that result of every operation is uniquely defined Non-Deterministic Algorithm: Outcome of an operation is not uniquely defined PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC ALGORITHMS
  • 69. Every non-deterministic algorithm makes use of three functions choice(S): arbitrarily choosing an element in a s et S for eg., x=choice(1,n) | means x€[1,n] failure(): unsuccessful completion success(): successful completion PRESENTED BY ARVIND KRISHNAA J THREE NEW FUNCTIONS
  • 70. NON DETERMINISTIC SEARCHING ND SORTING MAXIMUM CLIQUE PROBLEM 0/1 KANPSACK PROBLEM SATISFIABLITY and many, many more PRESENTED BY ARVIND KRISHNAA J SOME EXAMPLES OF NON-DETERMINISTIC ALGORITHMS
  • 71. nondeterministic_search(x) { int j=choice(1,n); if(A[j]==x) { cout<<j; success(); } cout<<‘0’; failure(); } PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC SEARCHING
  • 72. voidnondeterministic_sort(int A[],int n) { int B[SIZE],i,j; for(i=1;i<=n;i++) B[i]=0; for(i=1;i<=n;i++) { j=choice(1,n); if(B[j]) failure(); B[j]=A[i]; } for(i=1;i<=n;i++)//verify order if(B[i] > B[i+1]) failure(); for(i=1;i<=n;i++) cout<<B[i]<<‘ ‘; success(); } PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC SORTING
  • 73. void DCK(int G[]{SIZE],intn,int k) { S=null;//initially empty for(int i=1;i<=k;i++) { int t=choice(1,n); if(t is in S) failure(); S=S U {t}; } //now S contains k distinct vertices for(all pairs (i,j) such that i is in S,j is in S and i!=j) if((i,j) is not an edge of G) failure(); success(); } PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC Clique
  • 74. void DKP(int p[],int w[],intn,intm,intr,int x[]) { int W=0,P=0; for(int i=1;i<=n;i++) { x[i]=choice(0,1); W+=x[i]*w[i]; P+=x[i]*p[i]; } if((W>m) || (P < r)) failure(); else success(); } PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC KNAPSACK
  • 75. void eval(cnfE,int n) //determine whether the prop. formula is satisfiable //variables are x[1],x[2],x[3],...x[n] { int x[SIZE]; //choose a truth value assignment for(int i=1;i<=n;i++) x[i]=choice(0,1); if(E(x,n)) success(); else failure(); } PRESENTED BY ARVIND KRISHNAA J NON DETERMINISTIC SATISFIABLITY
  • 76. GRAPH PROBLEMS LIKE NODE COVERING PROBLEM GRAPH COMPLEMENT PROBLEM SCHEDULING PROBLEMS CODE GENERATION PROBLEM and many more PRESENTED BY ARVIND KRISHNAA J SOME EXAMPLES OF NP HARD PROBLEMS
  • 77. CHECK OUT THE TEXTBOOK PAGE NO571 PRESENTED BY ARVIND KRISHNAA J SOME EXAMPLES OF NP complete PROBLEMS
  • 78. APPROXIMATION RANDOMIZATION RESTRICTION PARAMETRIZATION HEURISTICS PRESENTED BY ARVIND KRISHNAA J BASIC TEHNIQUES INVOLVED IN SOLVING NP COMPLETE PROBLEMS OR IN SHORT PERFORMING A NON-DETERMINISTIC ANALYSIS ON THE PROBLEM
  • 79. ONE FINAL QUESTION Remember this: “No problem is too tough if u spend enuf time on it” -A great man PRESENTED BY ARVIND KRISHNAA J WHO IS THIS GREAT MAN???
  • 80. THANK YOU!!!!! PRESENTED BY ARVIND KRISHNAA J