Chap 4
Chap 4
algorithms
By Dr.Rinesh.S
Approximate Algorithms
• An Approximate Algorithm is a way of approach NP-
COMPLETENESS for the optimization problem. This technique
does not guarantee the best solution. The goal of an approximation
algorithm is to come as close as possible to the optimum value in a
reasonable amount of time which is at the most polynomial time. Such
algorithms are called approximation algorithm or heuristic algorithm.
• For the traveling salesperson problem, the optimization problem is to
find the shortest cycle, and the approximation problem is to find a
short cycle.
• For the vertex cover problem, the optimization problem is to find the
vertex cover with fewest vertices, and the approximation problem is to
find the vertex cover with few vertices.
Performance Ratios
• linear programming is a technique that helps us to find the optimum solution for a given problem,
an optimum solution is that solution that is the best possible outcome of a given particular problem.
• In simple terms, it is the method to find out how to do something in the best possible way in given
limited resources you need to do the optimum utilization of resources to achieve the best possible
result in a particular objective. such as least cost, highest margin, or least time on those resources
have alternate uses.
• The situation which requires a search for best values of the variables subject to certain constraints
are amendable programming analysis.
• These situations cannot be handled by the usual tools of Calculus or marginal analysis. The
calculus technique can only handle exactly equal constraints while this limitation does not exist in
the case of linear programming problems. A linear programming problem has two basic parts:
• First Part: It is the objective function that describes the primary purpose of the formation to
maximize some return or to minimize some.
• Second Part: It is a constant set, It is the system of equalities or inequalities which describe the
condition or constraints of the restriction under which Optimisation is to be accomplished.
What is a primal-dual algorithm?
• The primal-dual algorithm is a method for solving linear programs
inspired by the Ford–Fulkerson method. Instead of applying the
simplex method directly, we start at a feasible solution and then
compute the direction which is most likely to improve that solution.
Heuristic search strategies
• A heuristic search technique is a type of search performed by
artificial intelligence (AI) that looks to find a good solution, not
necessarily a perfect one, out of the available options.
Search Algorithm Terminologies:
Types of search algorithms
1. Breadth-first Search:
• Breadth-first search is the most common search strategy for traversing a tree or graph. This
algorithm searches breadthwise in a tree or graph, so it is called breadth-first search.
• BFS algorithm starts searching from the root node of the tree and expands all successor node at the
current level before moving to nodes of next level.
• The breadth-first search algorithm is an example of a general-graph search algorithm.
• Breadth-first search implemented using FIFO queue data structure.
• Advantages:
• BFS will provide a solution if any solution exists.
• If there are more than one solutions for a given problem, then BFS will provide the minimal
solution which requires the least number of steps.
• Disadvantages:
• It requires lots of memory since each level of the tree must be saved into memory to expand the
next level.
• BFS needs lots of time if the solution is far away from the root node.
Example:
2. Depth-first Search
• Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
• It is called the depth-first search because it starts from the root node and follows each path to its greatest
depth node before moving to the next path.
• DFS uses a stack data structure for its implementation.
• The process of the DFS algorithm is similar to the BFS algorithm.
• Note: Backtracking is an algorithm technique for finding all possible solutions using recursion.
• Advantage:
• DFS requires very less memory as it only needs to store a stack of the nodes on the path from root node to
the current node.
• It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right path).
• Disadvantage:
• There is the possibility that many states keep re-occurring, and there is no guarantee of finding the solution.
• DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.
Example:
3. Depth-Limited Search Algorithm: