The document discusses various optimization algorithms:
- Graph search algorithms like breadth-first search and Dijkstra's shortest path algorithm are used to find optimal paths in graphs.
- Depth-first search and linear ordering of partial orders are other graph algorithms covered.
- Network flows and linear programming are introduced as optimization problems where the goal is to find optimal solutions subject to constraints.
- Hill climbing and its application to the maximum flow problem in networks is also summarized.
[ICDE 2012] On Top-k Structural Similarity SearchPei Lee
In this talk, we talk about the following classic problem: given a node in a graph, how can we efficiently track the top-k similar nodes regarding this node, by simply checking the graph link structure? This talk is accompanying with the ICDE 2012 paper "On Top-k Structural Similarity Search", which can be found at http://www.cs.ubc.ca/~peil/research.html
This document discusses temporal graphs, which are graphs where nodes and edges are active for specific time instances. It provides examples of temporal graphs and compares them to non-temporal graphs. It then covers temporal graph traversal methods like depth-first search and breadth-first search, accounting for temporal constraints. Various path types in temporal graphs are defined, such as foremost paths, latest-departure paths, and fastest paths. Algorithms for finding these paths using a stream representation or graph transformation approach are outlined.
The document describes string comparison techniques using matrix algebra and seaweed matrices. It introduces the concept of semi-local string comparison, which involves comparing a whole string to substrings of another string. The key idea is representing string comparison matrices implicitly using seaweed matrices, which represent unit-Monge matrices. This allows developing algebraic techniques for efficiently multiplying such matrices using the algebra of braids and the seaweed monoid. These multiplication techniques can then be applied to problems like dynamic programming string comparison and comparing compressed strings.
The document discusses principles of clean code and provides examples of refactoring math functions to follow those principles. It begins with definitions of clean code and then shows how to refactor circle circumference, area, and sphere surface area/volume functions to have descriptive names, avoid literals, be self-explanatory without comments, and be easily testable. It emphasizes making code easy to understand, modify, and reuse through established conventions.
The document is a presentation on graph algorithms by Team Alpha. It summarizes Dijkstra's algorithm, BFS, DFS, and Bellman-Ford algorithm. It then provides examples of applying Bellman-Ford to find shortest paths in graphs, including detecting negative cycles.
The document defines topological sorting as a linear ordering of the vertices in a directed acyclic graph (DAG) such that if there is a path from vertex vi to vk, then vi appears before vk in the ordering. It provides an algorithm for finding a topological sort by initializing an array, finding vertices of degree zero, adding them to the array, and removing outgoing edges. It also describes an algorithm for enumerating all possible topological sorts by computing indegree counts and pushing vertices with indegree of zero onto a stack.
1. The document discusses depth-first search (DFS), including its recursive implementation which eliminates the need for an explicit stack. 2. DFS classifies the edges of a graph as tree edges, back edges, forward edges, or cross edges. Tree edges and back edges are the only possible edge types in an undirected graph searched with DFS. 3. Applications of DFS include finding cycles, articulation vertices, topological sorting of directed acyclic graphs, and finding strongly connected components.
[ICDE 2012] On Top-k Structural Similarity SearchPei Lee
In this talk, we talk about the following classic problem: given a node in a graph, how can we efficiently track the top-k similar nodes regarding this node, by simply checking the graph link structure? This talk is accompanying with the ICDE 2012 paper "On Top-k Structural Similarity Search", which can be found at http://www.cs.ubc.ca/~peil/research.html
This document discusses temporal graphs, which are graphs where nodes and edges are active for specific time instances. It provides examples of temporal graphs and compares them to non-temporal graphs. It then covers temporal graph traversal methods like depth-first search and breadth-first search, accounting for temporal constraints. Various path types in temporal graphs are defined, such as foremost paths, latest-departure paths, and fastest paths. Algorithms for finding these paths using a stream representation or graph transformation approach are outlined.
The document describes string comparison techniques using matrix algebra and seaweed matrices. It introduces the concept of semi-local string comparison, which involves comparing a whole string to substrings of another string. The key idea is representing string comparison matrices implicitly using seaweed matrices, which represent unit-Monge matrices. This allows developing algebraic techniques for efficiently multiplying such matrices using the algebra of braids and the seaweed monoid. These multiplication techniques can then be applied to problems like dynamic programming string comparison and comparing compressed strings.
The document discusses principles of clean code and provides examples of refactoring math functions to follow those principles. It begins with definitions of clean code and then shows how to refactor circle circumference, area, and sphere surface area/volume functions to have descriptive names, avoid literals, be self-explanatory without comments, and be easily testable. It emphasizes making code easy to understand, modify, and reuse through established conventions.
The document is a presentation on graph algorithms by Team Alpha. It summarizes Dijkstra's algorithm, BFS, DFS, and Bellman-Ford algorithm. It then provides examples of applying Bellman-Ford to find shortest paths in graphs, including detecting negative cycles.
The document defines topological sorting as a linear ordering of the vertices in a directed acyclic graph (DAG) such that if there is a path from vertex vi to vk, then vi appears before vk in the ordering. It provides an algorithm for finding a topological sort by initializing an array, finding vertices of degree zero, adding them to the array, and removing outgoing edges. It also describes an algorithm for enumerating all possible topological sorts by computing indegree counts and pushing vertices with indegree of zero onto a stack.
1. The document discusses depth-first search (DFS), including its recursive implementation which eliminates the need for an explicit stack. 2. DFS classifies the edges of a graph as tree edges, back edges, forward edges, or cross edges. Tree edges and back edges are the only possible edge types in an undirected graph searched with DFS. 3. Applications of DFS include finding cycles, articulation vertices, topological sorting of directed acyclic graphs, and finding strongly connected components.
This document discusses shortest path algorithms. It begins with an explanation of Dijkstra's algorithm for finding single source shortest paths in graphs with positive edge weights. It then discusses how the algorithm can be modified to handle graphs with negative edge weights by using Bellman-Ford algorithm, which iterates over all edges to relax distances and can detect negative cycles.
This document summarizes key concepts from a faculty development program on data structures, including graph applications, minimum spanning trees, shortest path algorithms, biconnected graphs, and Euler circuits. It provides examples and pseudocode for Prim's and Kruskal's minimum spanning tree algorithms and Dijkstra's shortest path algorithm. It also discusses identifying articulation points in a graph to determine if it is biconnected and conditions for the existence of Euler paths and circuits.
Sequential and parallel algorithm to find maximum flow on extended mixed netw...csandit
The problem of finding maximum flow in network
graph is extremely interesting and
practically applicable in many fields in our daily
life, especially in transportation. Therefore, a
lot of researchers have been studying this problem
in various methods. Especially in 2013, we
has developed a new algorithm namely, postflow-pull
algorithm to find the maximum flow on
traditional networks. In this paper, we revi
sed postflow-push methods to solve this
problem of finding maximum flow on extended mixed
network. In addition, to take more
advantage of multi-core architecture of t
he parallel computing system, we build this
parallel algorithm. This is a completely new method
not being announced in the world. The
results of this paper are basically systematized an
d proven. The idea of this algorithm is using
multi processors to work in parallel by postflow_p
ush algorithm. Among these processors,
there is one main processor managing data, sending
data to the sub processors, receiving data
from the sub-processors. The sub-processors simulta
neously execute their work and send their
data to the main processor until the job is finishe
d, the main processor will show the results of
the problem.
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...cscpconf
This document summarizes an algorithm for finding maximum flow on extended mixed networks using revised postflow-push methods and parallel processing. The key points are:
1. The authors revise postflow-push methods to solve the maximum flow problem on extended mixed networks, which model problems more accurately than traditional networks.
2. To take advantage of parallel computing, the authors develop a parallel algorithm where multiple processors work simultaneously using postflow-push until the problem is solved.
3. The algorithm balances inflow and outflow at vertices by pushing flow along outgoing edges and against incoming edges in the residual network until no unbalanced vertices remain.
Session 13 - Single Source Shortest Path Method.pptxSATHWIKCHAKRI
The document describes Dijkstra's algorithm for solving the single source shortest path problem. It begins with an introduction to the problem and provides an example graph with cities and distances. It then shows the pseudocode for Dijkstra's algorithm and walks through running the algorithm on the example graph step-by-step, updating the distances and selecting the next closest vertex on each iteration until all shortest paths from the source are determined.
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...Khoa Mac Tu
This document compares the Bellman-Ford algorithm and Dijkstra's algorithm for finding shortest paths in graphs. Both algorithms can be used to find single-source shortest paths, but Bellman-Ford can handle graphs with negative edge weights while Dijkstra's algorithm cannot. Bellman-Ford has a worst-case time complexity of O(n^2) while Dijkstra's algorithm has a better worst-case time complexity of O(n^2). However, Dijkstra's algorithm is more efficient in practice for graphs with non-negative edge weights. The document provides pseudocode to describe the procedures of each algorithm.
Project management techniques allow projects to be planned, monitored, and controlled effectively. The document discusses key project management steps including:
1. Representing the project as a network diagram with nodes and branches to show task dependencies and durations.
2. Using the Critical Path Method (CPM) to calculate earliest and latest start/finish times to determine the critical path and project completion time.
3. Conducting sensitivity analysis using the Program Evaluation and Review Technique (PERT) which considers probabilistic activity times to estimate mean times and variances for predicting project completion probabilities.
The document describes determining the critical path of a project using network analysis. It lists the steps as: 1) drawing the network diagram with activities and relationships, 2) calculating earliest and latest start/finish times, 3) determining total float for each activity, 4) identifying critical activities with zero total float, and 5) calculating the project duration. An example project is provided to demonstrate the process of identifying the critical path and activities with zero total float to determine the project completion time.
Distance vector routing is a distributed routing protocol that uses the Bellman-Ford algorithm to calculate the shortest paths between nodes. Each router periodically sends its routing table to its neighbors, containing the distance and next-hop information to reach all known destinations. Upon receiving updates from neighbors, routers recalculate path costs and propagate changes to ensure all routers converge on the shortest paths over time. While simple to implement, distance vector routing suffers from slow convergence and potential routing loops during network changes.
The document discusses the Critical Path Method (CPM) and Program Evaluation and Review Technique (PERT) for project scheduling. CPM determines the minimum project duration when activity times are known with certainty, while PERT estimates the probability of completing on time when activity times are uncertain. Both methods represent projects as networks and identify critical paths that must be followed to complete on schedule.
Network Diagrams: It is defined as “the identification of the project objectives and the ordered activity necessary to complete the project including the identification of resource types and quantities required.”
This document summarizes a research article that applied dynamic programming to determine the shortest route between Umuahia and Abuja in Nigeria. It begins with an abstract that outlines using a fixed-point iterative method within a metric space to model the problem. The introduction then provides background on dynamic programming techniques like backward recursion and Dijkstra's algorithm. It also describes other algorithms like greedy and Prim's algorithm for finding minimum spanning trees. The body of the document then gives mathematical definitions and results relevant to metric spaces and fixed points. It concludes that applying this dynamic programming approach found the shortest route between the two cities to be 702 km through several connecting cities.
This document discusses hardware architectures for deep learning. It covers various integer and floating point datatypes used in neural networks and their associated ranges and accuracy. It also discusses the evolution of Intel's SIMD instruction sets and their support for different data widths. The document introduces the roofline performance model and uses it to analyze the performance of a fully connected layer implementation on different hardware. It covers techniques for improving computational intensity, like loop splitting and reordering. Finally, it discusses computational transforms like Strassen's algorithm and Winograd that can reduce the operation count of matrix multiplication and convolution, respectively, though with some tradeoffs in numerical stability and memory usage.
The document summarizes various greedy algorithms and optimization problems that can be solved using greedy approaches. It discusses the greedy method, giving the definition that locally optimal decisions should lead to a globally optimal solution. Examples covered include picking numbers for largest sum, shortest paths, minimum spanning trees (using Kruskal's and Prim's algorithms), single-source shortest paths (using Dijkstra's algorithm), activity-on-edge networks, the knapsack problem, Huffman codes, and 2-way merging. Limitations of the greedy method are noted, such as how it does not always find the optimal solution for problems like shortest paths on a multi-stage graph.
The network layer is responsible for transporting data segments from source to destination hosts. It encapsulates segments into datagrams and delivers them to the transport layer. Network layer protocols run on every host and router. Routers examine header fields to forward datagrams appropriately based on destination addresses. The network layer handles addressing, routing, and intermediate forwarding of datagrams between source and destination hosts.
This document discusses algorithms for finding minimum spanning trees and shortest paths in graphs. It covers Prim's algorithm and Kruskal's algorithm for finding minimum spanning trees, and Dijkstra's algorithm for finding single-source shortest paths in graphs with non-negative edge weights. Examples are provided to illustrate how each algorithm works on sample graphs by progressively building up the minimum spanning tree or shortest path tree. Resources for further learning about data structures and algorithms are also listed.
This document discusses maximum flow problems and their application to flow networks. It begins by introducing flow networks and their representation as graphs. It then defines key concepts like source/sink vertices, flow conservation, and the goal of determining the maximum rate of flow from source to sink. The Ford-Fulkerson method for finding maximum flow is presented, using residual graphs and augmenting paths. The Max Flow Min Cut Theorem is stated, showing the relationship between maximum flow and minimum cut. Applications to problems like bipartite matching are discussed.
Algorithm Design and Complexity - Course 7Traian Rebedea
The document discusses algorithms for graphs, including breadth-first search (BFS) and depth-first search (DFS). BFS uses a queue to traverse nodes level-by-level from a starting node, computing the shortest path. DFS uses a stack, exploring as far as possible along each branch before backtracking, and computes discovery and finish times for nodes. Both algorithms color nodes white, gray, black to track explored status and maintain predecessor pointers to reconstruct paths. Common graph representations like adjacency lists and matrices are also covered.
Overview of Single Source Shortest Path
Types of Single Source Shortest Path Algorithm
Representation of Single Source Shortest Path
Initialization
Relaxation
Implementation of Dijkstra's Algorithm
Does Dijkstra’s Algorithm Always Work?
Implementation of Bellman-Ford Algorithm
Negative Weight Cycles in Bellman-Ford Algorithm
This document provides an overview of problem solving and Python programming. It discusses computational thinking and problem solving, including identifying computational problems, algorithms, building blocks of algorithms, and illustrative problems. It also discusses algorithmic problem solving techniques like iteration and recursion. Finally, it briefly introduces the course titled "GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING".
The document discusses Python programming concepts such as data types, variables, operators, and input/output. It provides examples of Python code and explains key features like:
- Python supports several data types including integers, floats, booleans, strings, and lists.
- Variables store and label values that can be of different data types. Variables are created using names.
- Operators like arithmetic, comparison, and logical operators are used to manipulate values.
- User input and output is handled through functions like print() and input().
- Comments, indentation, and quotation are syntax elements in Python code.
This document discusses shortest path algorithms. It begins with an explanation of Dijkstra's algorithm for finding single source shortest paths in graphs with positive edge weights. It then discusses how the algorithm can be modified to handle graphs with negative edge weights by using Bellman-Ford algorithm, which iterates over all edges to relax distances and can detect negative cycles.
This document summarizes key concepts from a faculty development program on data structures, including graph applications, minimum spanning trees, shortest path algorithms, biconnected graphs, and Euler circuits. It provides examples and pseudocode for Prim's and Kruskal's minimum spanning tree algorithms and Dijkstra's shortest path algorithm. It also discusses identifying articulation points in a graph to determine if it is biconnected and conditions for the existence of Euler paths and circuits.
Sequential and parallel algorithm to find maximum flow on extended mixed netw...csandit
The problem of finding maximum flow in network
graph is extremely interesting and
practically applicable in many fields in our daily
life, especially in transportation. Therefore, a
lot of researchers have been studying this problem
in various methods. Especially in 2013, we
has developed a new algorithm namely, postflow-pull
algorithm to find the maximum flow on
traditional networks. In this paper, we revi
sed postflow-push methods to solve this
problem of finding maximum flow on extended mixed
network. In addition, to take more
advantage of multi-core architecture of t
he parallel computing system, we build this
parallel algorithm. This is a completely new method
not being announced in the world. The
results of this paper are basically systematized an
d proven. The idea of this algorithm is using
multi processors to work in parallel by postflow_p
ush algorithm. Among these processors,
there is one main processor managing data, sending
data to the sub processors, receiving data
from the sub-processors. The sub-processors simulta
neously execute their work and send their
data to the main processor until the job is finishe
d, the main processor will show the results of
the problem.
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...cscpconf
This document summarizes an algorithm for finding maximum flow on extended mixed networks using revised postflow-push methods and parallel processing. The key points are:
1. The authors revise postflow-push methods to solve the maximum flow problem on extended mixed networks, which model problems more accurately than traditional networks.
2. To take advantage of parallel computing, the authors develop a parallel algorithm where multiple processors work simultaneously using postflow-push until the problem is solved.
3. The algorithm balances inflow and outflow at vertices by pushing flow along outgoing edges and against incoming edges in the residual network until no unbalanced vertices remain.
Session 13 - Single Source Shortest Path Method.pptxSATHWIKCHAKRI
The document describes Dijkstra's algorithm for solving the single source shortest path problem. It begins with an introduction to the problem and provides an example graph with cities and distances. It then shows the pseudocode for Dijkstra's algorithm and walks through running the algorithm on the example graph step-by-step, updating the distances and selecting the next closest vertex on each iteration until all shortest paths from the source are determined.
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...Khoa Mac Tu
This document compares the Bellman-Ford algorithm and Dijkstra's algorithm for finding shortest paths in graphs. Both algorithms can be used to find single-source shortest paths, but Bellman-Ford can handle graphs with negative edge weights while Dijkstra's algorithm cannot. Bellman-Ford has a worst-case time complexity of O(n^2) while Dijkstra's algorithm has a better worst-case time complexity of O(n^2). However, Dijkstra's algorithm is more efficient in practice for graphs with non-negative edge weights. The document provides pseudocode to describe the procedures of each algorithm.
Project management techniques allow projects to be planned, monitored, and controlled effectively. The document discusses key project management steps including:
1. Representing the project as a network diagram with nodes and branches to show task dependencies and durations.
2. Using the Critical Path Method (CPM) to calculate earliest and latest start/finish times to determine the critical path and project completion time.
3. Conducting sensitivity analysis using the Program Evaluation and Review Technique (PERT) which considers probabilistic activity times to estimate mean times and variances for predicting project completion probabilities.
The document describes determining the critical path of a project using network analysis. It lists the steps as: 1) drawing the network diagram with activities and relationships, 2) calculating earliest and latest start/finish times, 3) determining total float for each activity, 4) identifying critical activities with zero total float, and 5) calculating the project duration. An example project is provided to demonstrate the process of identifying the critical path and activities with zero total float to determine the project completion time.
Distance vector routing is a distributed routing protocol that uses the Bellman-Ford algorithm to calculate the shortest paths between nodes. Each router periodically sends its routing table to its neighbors, containing the distance and next-hop information to reach all known destinations. Upon receiving updates from neighbors, routers recalculate path costs and propagate changes to ensure all routers converge on the shortest paths over time. While simple to implement, distance vector routing suffers from slow convergence and potential routing loops during network changes.
The document discusses the Critical Path Method (CPM) and Program Evaluation and Review Technique (PERT) for project scheduling. CPM determines the minimum project duration when activity times are known with certainty, while PERT estimates the probability of completing on time when activity times are uncertain. Both methods represent projects as networks and identify critical paths that must be followed to complete on schedule.
Network Diagrams: It is defined as “the identification of the project objectives and the ordered activity necessary to complete the project including the identification of resource types and quantities required.”
This document summarizes a research article that applied dynamic programming to determine the shortest route between Umuahia and Abuja in Nigeria. It begins with an abstract that outlines using a fixed-point iterative method within a metric space to model the problem. The introduction then provides background on dynamic programming techniques like backward recursion and Dijkstra's algorithm. It also describes other algorithms like greedy and Prim's algorithm for finding minimum spanning trees. The body of the document then gives mathematical definitions and results relevant to metric spaces and fixed points. It concludes that applying this dynamic programming approach found the shortest route between the two cities to be 702 km through several connecting cities.
This document discusses hardware architectures for deep learning. It covers various integer and floating point datatypes used in neural networks and their associated ranges and accuracy. It also discusses the evolution of Intel's SIMD instruction sets and their support for different data widths. The document introduces the roofline performance model and uses it to analyze the performance of a fully connected layer implementation on different hardware. It covers techniques for improving computational intensity, like loop splitting and reordering. Finally, it discusses computational transforms like Strassen's algorithm and Winograd that can reduce the operation count of matrix multiplication and convolution, respectively, though with some tradeoffs in numerical stability and memory usage.
The document summarizes various greedy algorithms and optimization problems that can be solved using greedy approaches. It discusses the greedy method, giving the definition that locally optimal decisions should lead to a globally optimal solution. Examples covered include picking numbers for largest sum, shortest paths, minimum spanning trees (using Kruskal's and Prim's algorithms), single-source shortest paths (using Dijkstra's algorithm), activity-on-edge networks, the knapsack problem, Huffman codes, and 2-way merging. Limitations of the greedy method are noted, such as how it does not always find the optimal solution for problems like shortest paths on a multi-stage graph.
The network layer is responsible for transporting data segments from source to destination hosts. It encapsulates segments into datagrams and delivers them to the transport layer. Network layer protocols run on every host and router. Routers examine header fields to forward datagrams appropriately based on destination addresses. The network layer handles addressing, routing, and intermediate forwarding of datagrams between source and destination hosts.
This document discusses algorithms for finding minimum spanning trees and shortest paths in graphs. It covers Prim's algorithm and Kruskal's algorithm for finding minimum spanning trees, and Dijkstra's algorithm for finding single-source shortest paths in graphs with non-negative edge weights. Examples are provided to illustrate how each algorithm works on sample graphs by progressively building up the minimum spanning tree or shortest path tree. Resources for further learning about data structures and algorithms are also listed.
This document discusses maximum flow problems and their application to flow networks. It begins by introducing flow networks and their representation as graphs. It then defines key concepts like source/sink vertices, flow conservation, and the goal of determining the maximum rate of flow from source to sink. The Ford-Fulkerson method for finding maximum flow is presented, using residual graphs and augmenting paths. The Max Flow Min Cut Theorem is stated, showing the relationship between maximum flow and minimum cut. Applications to problems like bipartite matching are discussed.
Algorithm Design and Complexity - Course 7Traian Rebedea
The document discusses algorithms for graphs, including breadth-first search (BFS) and depth-first search (DFS). BFS uses a queue to traverse nodes level-by-level from a starting node, computing the shortest path. DFS uses a stack, exploring as far as possible along each branch before backtracking, and computes discovery and finish times for nodes. Both algorithms color nodes white, gray, black to track explored status and maintain predecessor pointers to reconstruct paths. Common graph representations like adjacency lists and matrices are also covered.
Overview of Single Source Shortest Path
Types of Single Source Shortest Path Algorithm
Representation of Single Source Shortest Path
Initialization
Relaxation
Implementation of Dijkstra's Algorithm
Does Dijkstra’s Algorithm Always Work?
Implementation of Bellman-Ford Algorithm
Negative Weight Cycles in Bellman-Ford Algorithm
This document provides an overview of problem solving and Python programming. It discusses computational thinking and problem solving, including identifying computational problems, algorithms, building blocks of algorithms, and illustrative problems. It also discusses algorithmic problem solving techniques like iteration and recursion. Finally, it briefly introduces the course titled "GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING".
The document discusses Python programming concepts such as data types, variables, operators, and input/output. It provides examples of Python code and explains key features like:
- Python supports several data types including integers, floats, booleans, strings, and lists.
- Variables store and label values that can be of different data types. Variables are created using names.
- Operators like arithmetic, comparison, and logical operators are used to manipulate values.
- User input and output is handled through functions like print() and input().
- Comments, indentation, and quotation are syntax elements in Python code.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help boost feelings of calmness, happiness and focus.
This document appears to be a test for a course on Design and Analysis of Algorithms. The test contains 3 parts: Part A has 5 short answer questions defining key algorithm concepts; Part B has 2 longer questions, one on asymptotic notation and important problem types, the other explaining non-recursive analysis and computing a Fibonacci series recursively; Part C contains one question asking to explain recursive analysis of mathematics in brief. The test covers fundamental algorithm topics like complexity analysis, problem types, and recursive versus non-recursive analysis.
The document discusses binary tree representation and traversal methods. It provides two main representations of binary trees - array and linked representations. It also describes different types of binary trees like full, complete, left-skewed, and right-skewed trees. The document then explains three common traversal techniques for binary trees - inorder, preorder, and postorder traversals. Algorithms and code snippets are given for each traversal. Finally, applications of binary tree traversals are discussed along with expression trees and converting infix to postfix notation using a stack.
This document discusses dynamic programming algorithms and NP-completeness. It begins by outlining 12 steps for proving that a new problem Pnew is NP-complete. It then provides examples of reducing the clique problem to the independent set problem to show they are equivalent. The document explains the concepts of instances, solutions, validity and reductions. It shows how to reduce any NP problem to the circuit satisfiability problem by building a circuit VI(S) that is equivalent to checking if a solution S is valid for a given instance I.
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Embedded machine learning-based road conditions and driving behavior monitoringIJECEIAES
Car accident rates have increased in recent years, resulting in losses in human lives, properties, and other financial costs. An embedded machine learning-based system is developed to address this critical issue. The system can monitor road conditions, detect driving patterns, and identify aggressive driving behaviors. The system is based on neural networks trained on a comprehensive dataset of driving events, driving styles, and road conditions. The system effectively detects potential risks and helps mitigate the frequency and impact of accidents. The primary goal is to ensure the safety of drivers and vehicles. Collecting data involved gathering information on three key road events: normal street and normal drive, speed bumps, circular yellow speed bumps, and three aggressive driving actions: sudden start, sudden stop, and sudden entry. The gathered data is processed and analyzed using a machine learning system designed for limited power and memory devices. The developed system resulted in 91.9% accuracy, 93.6% precision, and 92% recall. The achieved inference time on an Arduino Nano 33 BLE Sense with a 32-bit CPU running at 64 MHz is 34 ms and requires 2.6 kB peak RAM and 139.9 kB program flash memory, making it suitable for resource-constrained embedded systems.
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
1. UNIT II
OPTIMISATION ALGORITHMS
Optimization Problems-Graph Search Algorithms-Generic Search-Breadth-First
Search Dijkstra’s Shortest-Weighted-Path -Depth-First Search-Recursive Depth-First
Search-Linear Ordering of a Partial Order- Network Flows and Linear Programming-
Hill Climbing-Primal Dual Hill Climbing- Steepest Ascent Hill Climbing-Linear
Programming-Recursive Backtracking-Developing Recursive Backtracking
Algorithm- Pruning Branches-Satisfiability
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 1
2. Optimization Problems-Graph
Search Algorithms
• Generic Search
• Breadth First Search
• Dijkstra's Shortest Paths Algorithm
• Depth First Search
• Linear Order
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 2
3. Graph
a
c
b Node ~ city or computer
Edge ~ road or network
Undirected or Directed
A surprisingly large number of problems
in computer science can be expressed
as a graph theory problem.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 3
4. Generic Search-Graph Search
Specification: Reachability-from-single-source s
•<preCond>:
The input is a graph G
(either directed or undirected)
and a source node s.
•<postCond>:
Output all the nodes u that are
reachable by a path in G from s.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 4
5. Graph Search
Basic Steps:
s
u
• Suppose you know that u is reachable from s & there is an edge
from u to v
• You know that v is reachable from s
• Build up a set of reachable nodes.
v
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 5
7. Graph Search
EndingInitial ConditionsMake Progress
Maintain Loop InvDefine Exit ConditionDefine Step
Define Measure of ProgressDefine Loop InvariantsDefine Problem
km∞
79 km
to school
Exit
Exit
79 km 75 km
Exit
Exit
0 km Exit
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 7
9. BFS
What order are the nodes found?
So far, the nodes have been found in order of length from s.
<postCond>: Finds a shortest path from s
to each node v and its length.
To prove path is shortest:
Prove there is a path of this length.
Prove there are no shorter paths.
Give a path
(witness)
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 9
10. Basic Steps:
s
u
• The shortest path to u has length d & there is an edge from u to v
• There is a path to v with length d+1.
v
BFS
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 10
11. BFS
• What order are the nodes found?
• So far, the nodes have been found in order of length from s.
• <postCond>:
• Finds a shortest path from s to each node v and its length.
• Prove there are no shorter paths.
• When we find v, we know
there isn't a shorter path to it because ?
• Otherwise, we would have found it already.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 11
12. BFS
Data structure for storing tree:
•For each node v, store π(v) to be parent of v.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 12
13. Basic Steps:
s
u
v
Parent of v is
π(v)
π(v) = u.
BFS
Path to u & there is an edge from u to v
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 13
15. Dijkstra's Shortest-Weighted Paths
• Specification: Dijkstra's Shortest-Weighted Paths
• Reachability-from-single-source s
•<preCond>:
The input is a graph G
(either directed or undirected)
with positive edge weights
and a source node s.
•<postCond>:
Finds a shortest weighted path from s
to each node v and its length.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 15
17. • So far, the nodes have been found in order of length from
s.
• Is the same true for Dijkstra's Algorithm?
BFS
s
u
v
100
1
1
1
1
w
r
Which node is found first?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 17
18. • So far, the nodes have been found in order of length from s.
• Is the same true for Dijkstra's Algorithm?
s
u
v
100
1
1
1
1
w
r
• Which node is found first?
• It has the longest path from s.
BFS
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 18
19. • So far, the nodes have been found in order of length from s.
handled
• In what order do we handle the foundNotHandled nodes?
s
u
v
100
1
1
1
1
w
r
Dijkstra's
Handle node that “seems” to be closest to s.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 19
20. Dijkstra's
• So far, the nodes have been handled in order of length from s.
<postCond>:
• Finds a shortest weighted path
from s to each node v and its length.
• To prove path is shortest:
• Prove there is a path of this length.
• Prove there are no shorter paths.
• Give a path (witness)
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 20
21. Dijkstra's
• So far, the nodes have been handled in order of length from s.
• <postCond>:
• Finds a shortest weighted path
from s to each node v and its length.
• To prove path is shortest:
• Prove there is a path of this length.
• Prove there are no shorter paths.
• When we handle v, we know
there isn't a shorter path to it because?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2
21
22. Dijkstra's
Handle node that “seems” to be closest to s.
Need to keep approximate shortest distances.
•Path that we have “seen so far” will
be called handled paths.
•Let d(v) the length of the shortest
such path to v.
Basic Steps:
u vs
Which is
further?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 22
23. Basic Steps:
u
Dijkstra's
w<u,v>
v
s
The shortest of handled paths to v has length d(v)
• The shortest of handled paths to u has length d(u) & there is an edge
from u to v
• The shortest known path to v has length
min( d(v), d(u)+w<u,v> ).
Updating d(u).
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 23
27. Depth First Search
• Breadth first search makes a lot of sense for dating in general
actually.
• It suggests dating a bunch of people casually before getting
serious rather than having a series of five year relationships.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 27
31. Linear Order of a Partial Order
underwear
pants
socks
shoes
underwear
pants
socks
shoes
socks
underwear
pants
shoes
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 31
33. Linear Order
a
b h
c i
d j
e k
f l
g
<preCond>:
A Directed Acyclic
Graph(DAG)
<postCond>:
Find one valid linear order
….. l
Algorithm:
•Find a sink
•Put it last in order.
•Delete & Repeat
?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 33
34. Linear Order
a
b h
c i
d j
e k
f l
g
<preCond>:
A Directed Acyclic Graph(DAG)
<postCond>:
Find one validlinear order
….. l
Algorithm:
•Find a sink.
•Put it last in
order.
•Delete &
Repeat
Θ(n)
Θ(n2
)
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 34
35. Optimization Problems
•Ingredients:
•Instances: The possible inputs to the
problem.
•Solutions for Instance: Each instance
has an exponentially large set of
solutions.
•Cost of Solution: Each solution has an
easy to compute cost or value.
•Specification
•Preconditions: The input is one instance.
•Postconditions: An valid solution with
optimal cost. (minimum or maximum)
Network Flow & Linear Programming
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 35
36. •Instance:
•A Network is a directed graph G
•Edges represent pipes that carry
flow
•Each edge <u,v> has a maximum
capacity c<u,v>
•A source node s out of which flow
leaves
•A sink node t into which flow arrives
•Goal: Max Flow
Network Flow
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 36
37. Network Flow
• For some edges/pipes, it is not clear which direction the flow
should go
in order to maximize the flow from s to t.
• Hence we allow flow in both directions.
• Solution:
• The amount of flow F<u,v> through each edge.
• Flow F<u,v> can't exceed capacity c<u,v>.
• No leaks, no extra flow.
For each node v: flow in = flow out
∑u F<u,v> = ∑w F<v,w>
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 37
38. - ∑v F<v,s>
• Value of Solution:
• Flow from s into the network
– minus flow from the network back into s.
– rate(F) = ∑u F<s,u>
• Goal: Max Flow
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 38
39. •Value Solution C=<U,V>:
cap(C) = how much can flow from U to V
= ∑u∈U,v∈V c<u,v>
Min Cut
s
t
U
V
u
v
Goal: Min Cut
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 39
40. Max Flow = Min Cut
• Theorem:
• For all Networks MaxF rate(F) = MinC cap(C)
• Prove: ∀ F,C rate(F) ≤ cap(C)
• Prove: ∀ flow F, alg either
• finds a better flow F
• or finds cut C such that rate(F) = cap(C)
• Algotiyhm stops with an F and C for which rate(F) = cap(C)
• F witnesses that the optimal flow can't be less
• C witnesses that it can't be more.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 40
41. An Application: Matching
Sam Mary
Bob Beth
John Sue
Fred Ann
Who likes whom?
Who should be matched with whom?
so as many as possible matched
and nobody matched twice?
3 matches
Can we do better?
4 matches
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 41
42. An Application: Matching
s t
c<s,u> = 1
•Total flow out of u = flow into u ≤ 1
•Boy u matched to at most one girl.
1
c<v,t> = 1
•Total flow into v = flow out of v ≤ 1
•Girl v matched to at most one boy.
1
u v
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 42
43. Hill Climbing
Problems:
Can our Network Flow
Algorithm get stuck
in a local maximum?
Local Max
Global Max
No!
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 43
45. Hill Climbing
Problems:
Running time?
•If each iteration you take the biggest
step possible,
•Algorithm is poly time
• in number of nodes
• and number of bits in capacities.
• If each iteration you take path with the
fewest edges
•Algorithm is poly time
•in number of nodes
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 45
46. Taking the biggest step possible
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 46
50. Linear Programming
Linear Program:
•An optimization problem whose constraints and cost function are
linear functions
•Goal: Find a solution which optimizes the cost.
E.g.
Maximize Cost Function :
21x1 - 6x2 – 100x3 - 100x4
Constraint Functions:
5x1 + 2x2 +31x3 - 20x4 ≤ 21
1x1 - 4x2 +3x3 + 10x1 ³ 56
6x1 + 60x2 - 31x3 - 15x4 ≤ 200
…..
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 50
51. Primal-Dual Hill Climbing
Mars settlement has hilly landscape
and many layers of roofs.
Primal Problem:
•Exponential # of locations to stand.
•Find a highest one.
Dual problem:
•Exponential # of roofs.
•Find a lowest one.
Prove:
•Every roof is above every location to
stand.
∀ R ∀ L height(R) ≥ height(L)
⇒ height(Rmin) ≥ height(Lmax)
•Is there a gap?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 51
52. • Prove:
• For every location to stand either:
• the alg takes a step up or
• the alg gives a reason that explains why not
by giving a ceiling of equal height.
– i.e. ∀ L [∃ L’height(L’) ≥ height(L) or
∃ R height(R) = height(L)]
• But ∀ R ∀ L height(R) ≥ height(L)
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 52
53. Recursive Backtracking
• The brute force algorithm for an optimization problem is to simply
compute the cost or value of each of the exponential number of
possible solutions and return the best.
• A key problem with this algorithm is that it takes exponential time.
• Another (not obviously trivial) problem is how to write code that
enumerates over all possible solutions.
• Often the easiest way to do this is recursive backtracking.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 53
54. An Algorithm as a Sequence of Decisions:
• An algorithm for finding an optimal solution for your instance
must make a sequence of small decisions about the solution
• “Do we include the first object in the solution or not?”
• “Do we include the second?”
• “The third?” . . . , or “At the first fork in the road, do we go
left or right?”
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 54
55. • “At the second fork which direction do we go?” “At the
third?” . . . .
• As one stack frame in the recursive algorithm, our task is to
deal only with the first of these decisions.
• A recursive friend will deal with the rest
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 55
56. Searching for the Best Animal
• Searching through a large set of objects, say for the best
animal at the zoo.
• we break the search into smaller searches, each of which we
delegate to a friend.
• We might ask one friend for the best vertebrate and another for
the best invertebrate.
• We will take the better of these best as our answer.
• This algorithm is recursive.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 56
57. • The friend with the vertebrate task asks a friend to find the best
mammal, another for the best bird, and another for the best reptile.
A Classification Tree of Solutions:
• This algorithm unwinds into the tree of stack frames that directly
mirrors the taxonomy tree that classifies animals.
• Each solution is identified with a leaf.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 57
58. Classification Tree of Animals
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 58
59. The Little Bird Abstraction:
•A little bird abstraction to help focus on two of the most difficult
and creative parts of designing a recursive backtracking algorithm.
A Flock of Stupid Birds vs.wise Little Bird:
A Flock of Stupid Birds:
•whether the optimal solution is a mammal, a bird, or a reptile has K
different answers
•Giving her the benefit of doubt, we ask a friend to give us the
optimal solution from among those that are consistent with this
answer.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 59
60. • At least one of these birds must have been telling us the truth.
Wise Little Bird:
• If little bird answers correctly, designing an algorithm would be a
lot easier
• Ask the little bird “Is the best animal a bird, a mammal, a reptile, or
a fish?”
• Little Bird tells us a mammal.
• Just ask our friend for the best mammal.
• Trusting the little bird and the friend, we give this as the best
animal.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 60
61. Developing a Recursive Backtracking Algorithm
Objectives:
•Understand backtracking algorithms and use them to solve
problems
•Use recursive functions to implement backtracking algorithms
•How the choice of data structures can affect the efficiency of a
program?
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 61
62. Backtracking
• Backtracking
– A strategy for guessing at a solution and backing up when an
impasse is reached
• Recursion and backtracking can be combined to solve problems
• Eight-Queens Problem
– Place eight queens on the chessboard so that no queen can
attack any other queen
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 62
63. The Eight Queens Problem
• One strategy: guess at a solution
– There are 4,426,165,368 ways to arrange 8 queens on a
chessboard of 64 squares
• An observation that eliminates many arrangements from
consideration
– No queen can reside in a row or a column that contains
another queen
• Now: only 40,320 (8!) arrangements of queens to be
checked for attacks along diagonals
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 63
64. • Providing organization for the guessing strategy
– Place queens one column at a time
– If you reach an impasse, backtrack to the previous
column
A solution to the Eight Queens problem
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 64
65. The Eight Queens Problem
• A recursive algorithm that places a queen in a column
– Base case
• If there are no more columns to consider
– You are finished
– Recursive step
• If you successfully place a queen in the current column
– Consider the next column
• If you cannot place a queen in the current column
– You need to backtrack
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 65
66. The Eight Queens Problem
a)Five queens that cannot attack each other,
but that can attack all of column 6;
b)Backtracking to column 5 to try another
square for the queen;
c)Backtracking to column 4 to try another
square for the queen and then considering
column 5 again
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 66
67. Pruning Branches
• The typical reasons why an entire branch of the solution
classification tree can be pruned off.
Invalid Solutions:
• It happens partway down the tree the algorithm has already received
enough information about the solution
• Then it determine that it contains a conflict or defect making any
such solution invalid.
• The algorithm can stop recursing at this point and backtrack.
• This effectively prunes off the entire subtree of solutions rooted at
this node in the tree.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 67
68. No Highly Valued Solutions:
•The algorithm arrives at the root of a subtree, it might realize that no
solutions within this subtree are rated sufficiently high to be optimal
•Perhaps because the algorithm has already found a solution
probably better than all of these.
•Again, the algorithm can prune this entire subtree from its search.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 68
69. Greedy Algorithms:
•Greedy algorithms are effectively recursive backtracking
algorithms with extreme pruning.
•Whenever the algorithm has a choice as to which little bird’s
answer to take
•Then it looks best according to some greedy criterion.
Modifying Solutions:
•Modifying any possible solution that is not consistent with the
latest choice into onethat has at least as good value and is consistent
with this choice.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 69
70. Satisfiability
• A famous optimization problem is called satisfiability.
• The recursive backtracking algorithm is referred to as the
Davis–Putnam algorithm.
• An example of an algorithm whose running time is
exponential for worst case inputs
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 70
71. Satisfiability Problem
Instances:
•An instance (input) consists of a set of constraints on the assignment
to the binary variables x1, x2, . . . , xn.
•A typical constraint might be x1 or x3 or x8, equivalently that either
x1 is true, x3 is false, or x8 is true.
Solutions:
•Each of the 2n assignments is a possible solution.
•An assignment is valid for the given instance if it satisfies all of the
constraints.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 71
72. Measure of Success:
• An assignment is assigned the value one if it satisfies all of the
constraints, and the value zero otherwise.
Goal:
•Given the constraints, the goal is to find a satisfying assignment.
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 72
74. Running Time:
•If no pruning is done, then the running time is (2n), as all 2n
assignments are tried.
•Considerable pruning needs to occur to make the algorithm
polynomial-time.
•Certainly in the worst case, the running time is 2(n).
IFETCE/M.E(CSE)/I YEAR/I SEM/CP7102/ADS/UNIT-II/PPT/VER 1.2 74