KEMBAR78
ETCS262A-Analysis of design Algorithm.pptx
Faculty Name: Ms. Nupur Jangu
Assistant Professor
CSE,SOET
Subject: Analysis And Design Of
Algorithms
Course Code : ETCS220A
Program: B.Tech CSE IV, B.Tech CSE
AIML IV,BCA IV,BSC IV
Agenda
Fundamental Algorithmic Strategies
Brute -Force
Branch-and-Bound
Heuristics – characteristics and their application domains
Support Material &References
Fundamental Algorithmic Strategies
 Algorithmic strategies are systematic approaches to problem-solving that guide
the design and implementation of algorithms.
 Each strategy has its unique characteristics, strengths, and weaknesses, making
them suitable for specific types of problems.
 Various Algorithmic Strategies are as follows:
• Brute-Force: Exhaustive search method exploring all possible solutions.
• Greedy: Make locally optimal choices at each step to achieve a global optimum.
• Dynamic Programming: Break down a problem into smaller subproblems and
solve them independently, storing solutions to avoid redundant computations.
• Branch-and-Bound: Systematically search the solution space, pruning branches
that cannot lead to optimal solutions.
• Backtracking: Incrementally build solutions and backtrack when a dead-end is
reached.
Brute-Force
 Brute-force is a straightforward algorithmic strategy that systematically
explores all possible solutions to a problem until the correct solution is
found.
 It involves checking every possible combination to find the solution, making
it exhaustive and deterministic.
 It’s a generic approach to problem-solving that’s employed when the issue is
small enough to make an in-depth investigation possible.
 Many problems are solved in day-to-day life using the brute force strategy,
for example,
• exploring all the paths to a nearby market to find the minimum shortest
path.
• Arranging the books in a rack using all the possibilities to optimize the rack
spaces, etc.
Strengths and Weaknesses
 Strengths:
 Guarantees finding the optimal solution.
 Simple and easy to implement for small problem instances.
 Weaknesses:
 Inefficient for large problem spaces due to the exponential growth of
possibilities.
 Often not practical for complex problems due to its time and resource
requirements.
Travelling salesman Problem using
Brute Force approach
 Given a set of cities and distance between every pair of cities, the problem is to
find the shortest possible route that visits every city exactly once and returns to
the starting point."
 In figure 1 four cities are shown as graph and the cost of each edges are also
shown there. The salesman start from city 1 and travel each cities(nodes) and
come back to city 1.
 In brute-force approach if the number of vertices is N, (N-1)! routes are
possible.
Fig 1: Cities and cost to travel among those
TSP Brute Force cont….
Fig 2 : State Space Tree
• As shown in figure 2 let’s take the
starting point(city 1) as the root node
and other three points(city 2,3,4) as
the leaf nodes of the node 1.
• Do the same thing to every leaf node
until you reach the starting point(city
1 or node 1).Then find the total cost
of every possible routes and the
minimum cost is our solution.
• Here in figure 2 the minimum cost is
80 so the possible routes are 1–2–4–
3–1 and 1–3–4–2–1.Both routes has
the same cost 80 so the salesman can
travel from any route from that.
TSP Brute Force cont….
As shown in figure 2 let’s take the starting point(city 1) as the root node
and other three points(city 2,3,4) as the leaf nodes of the node 1.Do the
same thing to every leaf node until you reach the starting point(city 1 or
node 1).Then find the total cost of every possible routes and the
minimum cost is our solution.
Here in figure 2 the minimum cost is 80 so the possible routes are 1–2–
4–3–1 and 1–3–4–2–1.Both routes has the same cost 80 so the salesman
can travel from any route from that. Now lets talk about dynamic
programming approach.
0/1 Knapsack using Brute Force
approach
 Given N items where each item has some weight and profit associated with it
and also given a bag with capacity W, [i.e., the bag can hold at most W
weight in it]. The task is to put the items into the bag such that the sum of
profits associated with them is the maximum possible.
 Note: The constraint here is we can either put an item completely into the
bag or cannot put it at all [It is not possible to put a part of an item into the
bag].
 For the knapsack problem, the brute force approach involves generating all
possible combinations of items and checking which combination provides
the maximum value without exceeding the weight limit of the knapsack.
 For n items, there will be 2^n solutions. Therefore, the time complexity will
be O(2^n) for this problem if we use a brute-force solution.
0/1 Knapsack using Brute Force…
Branch-and-Bound
 The Branch and Bound Algorithm is a method used in combinatorial
optimization problems to systematically search for the best solution.
 It works by dividing the problem into smaller subproblems, or branches, and
then eliminating certain branches based on bounds on the optimal solution.
This process continues until the best solution is found or all branches have
been explored.
 Branch and Bound is commonly used in problems like the traveling salesman
and job scheduling.
Travelling salesman Problem using
Branch and Bound approach
 Given a set of cities and distance between every pair of cities, the problem is to
find the shortest possible route that visits every city exactly once and returns to
the starting point."
Fig: Cities and cost to travel among those
TSP Branch and Bound….
Fig: State Space Tree
• As we can see from the side diagram,
every node has a cost associated with
it. When we go from the city i to city j,
the cost of a node j will be the sum of
the parent node i, the cost of an edge
(i, j), and the lower bound of the path
starting at node j.
• As the root node is the first node to
be expanded, it doesn’t have any
parent. So, the cost will be only the
lower bound of the path starting at
the root.
0/1 Knapsack using Branch-and-
Bound
 For current node in tree, we compute a bound on best possible solution that
we can get if we down this node. If the bound on best possible solution itself
is worse than current best (best computed so far), then we ignore the
subtree rooted with the node.
 Note that the cost through a node includes two costs.
1) Cost of reaching the node from the root (When we reach a node, we have
this cost computed)
2) Cost of reaching an answer from current node to a leaf (We compute a
bound on this cost to decide whether to ignore subtree with this node or not).
0/1 Knapsack using Branch-and-
Bound
Heuristics – characteristics and
their application domains
 Heuristics are problem-solving techniques or rules of thumb that simplify
decision-making processes and guide problem-solving toward efficient and
practical solutions.
 Unlike algorithms that guarantee an optimal solution, heuristics provide
quick, practical, and often approximate solutions to complex problems.
 They are based on experience, intuition, or domain-specific knowledge and
prioritize speed and simplicity over accuracy.
 Heuristics are commonly used in various fields, including computer science,
artificial intelligence, psychology, economics, and decision theory.
 They play a crucial role in problem-solving, decision-making,
optimization, and search algorithms, especially when finding the
optimal solution is impractical or computationally expensive.
 Examples of heuristics include genetic algorithms, simulated
annealing, hill climbing, and greedy algorithms.
Heuristics cont….
Characteristics of Heuristics
 Efficiency: Heuristics prioritize efficiency over optimality, aiming to find
satisfactory solutions within a reasonable time frame.
 Problem-Specific: Heuristics are tailored to specific problem domains,
utilizing domain knowledge or rules to guide the search process.
 Approximate Solutions: Heuristics often produce approximate solutions that
may not be optimal but are acceptable for practical purposes.
 Iterative Improvement: Some heuristics involve iterative improvement by
gradually refining solutions until satisfactory results are achieved.
 Trade-off: Heuristics often involve a trade-off between solution quality and
computational resources, providing fast but acceptable solutions.
Application Domains
 Optimization Problems: Heuristics are widely used in optimization problems
where finding the optimal solution is computationally expensive or
infeasible.
 Combinatorial Problems: Heuristics are effective in combinatorial problems
such as routing, scheduling, and allocation, where the search space is vast.
 Constraint Satisfaction Problems: Heuristics are applied in constraint
satisfaction problems to efficiently explore the solution space and satisfy
given constraints.
 Machine Learning: Heuristics play a crucial role in machine learning
algorithms, guiding the search for optimal models or parameters.
 Game Playing: Heuristics are utilized in game-playing algorithms to evaluate
board states and make informed decisions, especially in games with complex
branching factors.
Support Material & References
Text Books
1.Introduction to Algorithms, 4TH Edition, Thomas H Cormen, Charles E Lieserson, Ronald
Rivest and Clifford Stein, MIT Press/McGraw-Hill.
2.Fundamentals of Algorithms – E. Horowitz et al.
References
1. Analysis of Algorithms | Coursera
2. Design and analysis of algorithms - Course (nptel.ac.in)
3. Free Algorithms Course with Online Certificate - Enrol Now (mygreatlearning.com)
4. Introduction Data Structures and Algorithms Tutorial - GeeksforGeeks
THANK YOU

ETCS262A-Analysis of design Algorithm.pptx

  • 1.
    Faculty Name: Ms.Nupur Jangu Assistant Professor CSE,SOET Subject: Analysis And Design Of Algorithms Course Code : ETCS220A Program: B.Tech CSE IV, B.Tech CSE AIML IV,BCA IV,BSC IV
  • 2.
    Agenda Fundamental Algorithmic Strategies Brute-Force Branch-and-Bound Heuristics – characteristics and their application domains Support Material &References
  • 3.
    Fundamental Algorithmic Strategies Algorithmic strategies are systematic approaches to problem-solving that guide the design and implementation of algorithms.  Each strategy has its unique characteristics, strengths, and weaknesses, making them suitable for specific types of problems.  Various Algorithmic Strategies are as follows: • Brute-Force: Exhaustive search method exploring all possible solutions. • Greedy: Make locally optimal choices at each step to achieve a global optimum. • Dynamic Programming: Break down a problem into smaller subproblems and solve them independently, storing solutions to avoid redundant computations. • Branch-and-Bound: Systematically search the solution space, pruning branches that cannot lead to optimal solutions. • Backtracking: Incrementally build solutions and backtrack when a dead-end is reached.
  • 4.
    Brute-Force  Brute-force isa straightforward algorithmic strategy that systematically explores all possible solutions to a problem until the correct solution is found.  It involves checking every possible combination to find the solution, making it exhaustive and deterministic.  It’s a generic approach to problem-solving that’s employed when the issue is small enough to make an in-depth investigation possible.  Many problems are solved in day-to-day life using the brute force strategy, for example, • exploring all the paths to a nearby market to find the minimum shortest path. • Arranging the books in a rack using all the possibilities to optimize the rack spaces, etc.
  • 5.
    Strengths and Weaknesses Strengths:  Guarantees finding the optimal solution.  Simple and easy to implement for small problem instances.  Weaknesses:  Inefficient for large problem spaces due to the exponential growth of possibilities.  Often not practical for complex problems due to its time and resource requirements.
  • 6.
    Travelling salesman Problemusing Brute Force approach  Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route that visits every city exactly once and returns to the starting point."  In figure 1 four cities are shown as graph and the cost of each edges are also shown there. The salesman start from city 1 and travel each cities(nodes) and come back to city 1.  In brute-force approach if the number of vertices is N, (N-1)! routes are possible. Fig 1: Cities and cost to travel among those
  • 7.
    TSP Brute Forcecont…. Fig 2 : State Space Tree • As shown in figure 2 let’s take the starting point(city 1) as the root node and other three points(city 2,3,4) as the leaf nodes of the node 1. • Do the same thing to every leaf node until you reach the starting point(city 1 or node 1).Then find the total cost of every possible routes and the minimum cost is our solution. • Here in figure 2 the minimum cost is 80 so the possible routes are 1–2–4– 3–1 and 1–3–4–2–1.Both routes has the same cost 80 so the salesman can travel from any route from that.
  • 8.
    TSP Brute Forcecont…. As shown in figure 2 let’s take the starting point(city 1) as the root node and other three points(city 2,3,4) as the leaf nodes of the node 1.Do the same thing to every leaf node until you reach the starting point(city 1 or node 1).Then find the total cost of every possible routes and the minimum cost is our solution. Here in figure 2 the minimum cost is 80 so the possible routes are 1–2– 4–3–1 and 1–3–4–2–1.Both routes has the same cost 80 so the salesman can travel from any route from that. Now lets talk about dynamic programming approach.
  • 9.
    0/1 Knapsack usingBrute Force approach  Given N items where each item has some weight and profit associated with it and also given a bag with capacity W, [i.e., the bag can hold at most W weight in it]. The task is to put the items into the bag such that the sum of profits associated with them is the maximum possible.  Note: The constraint here is we can either put an item completely into the bag or cannot put it at all [It is not possible to put a part of an item into the bag].  For the knapsack problem, the brute force approach involves generating all possible combinations of items and checking which combination provides the maximum value without exceeding the weight limit of the knapsack.  For n items, there will be 2^n solutions. Therefore, the time complexity will be O(2^n) for this problem if we use a brute-force solution.
  • 10.
    0/1 Knapsack usingBrute Force…
  • 11.
    Branch-and-Bound  The Branchand Bound Algorithm is a method used in combinatorial optimization problems to systematically search for the best solution.  It works by dividing the problem into smaller subproblems, or branches, and then eliminating certain branches based on bounds on the optimal solution. This process continues until the best solution is found or all branches have been explored.  Branch and Bound is commonly used in problems like the traveling salesman and job scheduling.
  • 12.
    Travelling salesman Problemusing Branch and Bound approach  Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route that visits every city exactly once and returns to the starting point." Fig: Cities and cost to travel among those
  • 13.
    TSP Branch andBound…. Fig: State Space Tree • As we can see from the side diagram, every node has a cost associated with it. When we go from the city i to city j, the cost of a node j will be the sum of the parent node i, the cost of an edge (i, j), and the lower bound of the path starting at node j. • As the root node is the first node to be expanded, it doesn’t have any parent. So, the cost will be only the lower bound of the path starting at the root.
  • 14.
    0/1 Knapsack usingBranch-and- Bound  For current node in tree, we compute a bound on best possible solution that we can get if we down this node. If the bound on best possible solution itself is worse than current best (best computed so far), then we ignore the subtree rooted with the node.  Note that the cost through a node includes two costs. 1) Cost of reaching the node from the root (When we reach a node, we have this cost computed) 2) Cost of reaching an answer from current node to a leaf (We compute a bound on this cost to decide whether to ignore subtree with this node or not).
  • 15.
    0/1 Knapsack usingBranch-and- Bound
  • 16.
    Heuristics – characteristicsand their application domains  Heuristics are problem-solving techniques or rules of thumb that simplify decision-making processes and guide problem-solving toward efficient and practical solutions.  Unlike algorithms that guarantee an optimal solution, heuristics provide quick, practical, and often approximate solutions to complex problems.  They are based on experience, intuition, or domain-specific knowledge and prioritize speed and simplicity over accuracy.  Heuristics are commonly used in various fields, including computer science, artificial intelligence, psychology, economics, and decision theory.
  • 17.
     They playa crucial role in problem-solving, decision-making, optimization, and search algorithms, especially when finding the optimal solution is impractical or computationally expensive.  Examples of heuristics include genetic algorithms, simulated annealing, hill climbing, and greedy algorithms. Heuristics cont….
  • 18.
    Characteristics of Heuristics Efficiency: Heuristics prioritize efficiency over optimality, aiming to find satisfactory solutions within a reasonable time frame.  Problem-Specific: Heuristics are tailored to specific problem domains, utilizing domain knowledge or rules to guide the search process.  Approximate Solutions: Heuristics often produce approximate solutions that may not be optimal but are acceptable for practical purposes.  Iterative Improvement: Some heuristics involve iterative improvement by gradually refining solutions until satisfactory results are achieved.  Trade-off: Heuristics often involve a trade-off between solution quality and computational resources, providing fast but acceptable solutions.
  • 19.
    Application Domains  OptimizationProblems: Heuristics are widely used in optimization problems where finding the optimal solution is computationally expensive or infeasible.  Combinatorial Problems: Heuristics are effective in combinatorial problems such as routing, scheduling, and allocation, where the search space is vast.  Constraint Satisfaction Problems: Heuristics are applied in constraint satisfaction problems to efficiently explore the solution space and satisfy given constraints.  Machine Learning: Heuristics play a crucial role in machine learning algorithms, guiding the search for optimal models or parameters.  Game Playing: Heuristics are utilized in game-playing algorithms to evaluate board states and make informed decisions, especially in games with complex branching factors.
  • 20.
    Support Material &References Text Books 1.Introduction to Algorithms, 4TH Edition, Thomas H Cormen, Charles E Lieserson, Ronald Rivest and Clifford Stein, MIT Press/McGraw-Hill. 2.Fundamentals of Algorithms – E. Horowitz et al. References 1. Analysis of Algorithms | Coursera 2. Design and analysis of algorithms - Course (nptel.ac.in) 3. Free Algorithms Course with Online Certificate - Enrol Now (mygreatlearning.com) 4. Introduction Data Structures and Algorithms Tutorial - GeeksforGeeks
  • 21.

Editor's Notes

  • #2 New Courses replaced with New Programmes
  • #3 New Courses replaced with New Programmes
  • #4 New Courses replaced with New Programmes
  • #6 New Courses replaced with New Programmes
  • #7 New Courses replaced with New Programmes
  • #8 New Courses replaced with New Programmes
  • #9 New Courses replaced with New Programmes
  • #13 New Courses replaced with New Programmes
  • #14 New Courses replaced with New Programmes
  • #21 New Courses replaced with New Programmes