SlideShare a Scribd company logo
1 of 34
Advanced Artificial
Intelligence
MSCS 1
Lecture 5
Greedy search
• Greedy search is a variation of the A* algorithm, where g(node) is set
to zero, so that only h(node) is used to evaluate suitable paths. In this
way, the algorithm always selects the path that has the lowest
heuristic value or estimated distance (or cost) to the goal.
• Greedy search is an example of a best-first strategy.
• Greedy-search methods tend to be reasonably efficient, although in
the worst case, like depth-first search, it may never find a solution at
all.
Knapsack problem
• The knapsack problem is an interesting illustration of the use of
greedy search algorithms and their pitfalls. The fractional knapsack
problem can be expressed as follows:
• A man is packing items into his knapsack. He wants to take the most
valuable items he can, but there is a limit on how much weight he can
fit in his knapsack. Each item has a weight wi and is profit pi. He can
only fit a total weight of W in his knapsack.
Knapsack problem
• The items that he wants to take are things that can be broken up and still
retain their value (like flour or milk), and he is The items that he wants to
take are things that can be broken up and still retain their value (like flour
or milk), and he is able to take fractions of items. Hence, the problem is
called the fractional knapsack problem.
• In solving this problem, a greedy-search algorithm provides the best
solution.
• The problem is solved by calculating the value per unit weight of each item:
pi/wi, and then taking as much as he can carry of the item with the
greatest
value per unit weight. If he still has room, he moves on to the item with the
next highest value per unit weight, and so on.
Fractional Knapsack problem
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Items N = 7
Bag capacity M = 15
Fractional Knapsack problem
• Now we have a bag with capacity of 15. lets suppose 15 kg.
• Now we want to transfer this bag from one location to another.
• We are facing this problem in daily life.
• Now problem is to filling of the objects in a container.
• If you put all the objects in the bag with the capacity, there is no
problem.
• But the objects weight is more than the bag capacity, here the
problem start.
Fractional Knapsack problem
• We should maximize the profit.
• So this problem is optimization problem.
• Can we apply the greedy method to solve this problem?
• Yes, if it is suitable.
• So what are the constraints here?
• The bag capacity is 15, so all the objects which we want to transfer
should be <= 15.
Fractional Knapsack problem
• For this problem we have many solutions.
• The optimal result is to gain a maximum profit.
• X = {x1, x2, x3, x4, x5, x6, x7}
• We can say this problem is a fractional problem
• 0 ≤ X ≤ 1
Fractional Knapsack problem
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
• Items n = 7
• Bag capacity m = 15
Fractional Knapsack problem
• Profit of each item per kg is
• X1 = 5, x2=1.3, x3=3, x4=1, x5=6, x6=4.5, x7=3
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Items n = 7
Bag capacity m = 15
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Items n = 7
Bag capacity m = 15
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Fractional Knapsack problem
• Now we select the items on the basis of their profit
Objects 0 1 2 3 4 5 6 7
Profits p 10 5 15 7 6 18 3
Weights w 2 3 5 7 1 4 1
Max profit p/w 5 1.3 3 1 6 4.5 3
Items n = 7
Bag capacity m = 15
A* algorithm for searching
• Informed searching algorithm
• A* Search algorithm is one of the best and popular technique used in
path-finding and graph traversals.
• Informally speaking, A* Search algorithms, unlike other traversal
techniques, it has “brains”. What it means is that it is really a smart
algorithm which separates it from the other conventional algorithms.
• And it is also worth mentioning that many games and web-based
maps use this algorithm to find the shortest path very efficiently
(approximation).
A* algorithm for searching
• A* algorithms are similar to best-first search but use a somewhat
more complex heuristic to select a path through the tree. The best-
first algorithm always extends paths that involve moving to the node
that appears to be closest to the goal, but it does not take into
account the cost of the path to that node so far.
• The A* algorithm operates in the same manner as best-first search
but uses the following function to evaluate nodes:
• f(n) = g(n) + h(n)
A* algorithm for searching
• g(n)--- actual cost from start node to n.
• h(n)--- estimation cost from n to goal node.
A* algorithm for searching
• S is start node and G is goal node.
• A* is an admissible algorithm which mean that it will give an optimal
solution.
A* algorithm for searching
• We are taking a directed graph in this example. We also can take a
tree to solve this problem. From S to B, 4 is actual value and in red
color 12 is heuristic value.
A* algorithm for searching
• Explore S, SB, SC.
A* algorithm for searching
• We explore SCE, SCD, SBF, SBE
A* algorithm for searching
• We explore SCE, SCD, SBF, SBE
A* algorithm for searching
• We explore SCDEG
A* algorithm for searching
• Time complexity
• T(C) = O(v+E)
• In artificial intelligence point of view
• O(b^d)
• Where b is the branch factor, d is the depth.

More Related Content

What's hot

Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)Ridhima Chowdhury
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)Madhu Bala
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptRuchika Sinha
 
Fractional knapsack class 13
Fractional knapsack class 13Fractional knapsack class 13
Fractional knapsack class 13Kumar
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic ProgrammingFenil Shah
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsackAmin Omi
 
Dynamic Programming-Knapsack Problem
Dynamic Programming-Knapsack ProblemDynamic Programming-Knapsack Problem
Dynamic Programming-Knapsack ProblemAmrita Yadav
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cutMayank Garg
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmAcad
 

What's hot (20)

Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)
 
Rough K Means - Numerical Example
Rough K Means - Numerical ExampleRough K Means - Numerical Example
Rough K Means - Numerical Example
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Fractional knapsack class 13
Fractional knapsack class 13Fractional knapsack class 13
Fractional knapsack class 13
 
Red black tree
Red black treeRed black tree
Red black tree
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Dynamic Programming-Knapsack Problem
Dynamic Programming-Knapsack ProblemDynamic Programming-Knapsack Problem
Dynamic Programming-Knapsack Problem
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
 

Similar to AI Greedy Search and A* Algorithm Guide

Greedy method1
Greedy method1Greedy method1
Greedy method1Rajendran
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptRuchika Sinha
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sJay Patel
 
Optimization problems
Optimization problemsOptimization problems
Optimization problemsRuchika Sinha
 
module3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfmodule3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfShiwani Gupta
 
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"22bcs058
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptdakccse
 
Solving 0-1 knapsack problems based on amoeboid organism algorithm
Solving 0-1 knapsack problems based on amoeboid organism algorithmSolving 0-1 knapsack problems based on amoeboid organism algorithm
Solving 0-1 knapsack problems based on amoeboid organism algorithmjuanjo_23
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptBinayakMukherjee4
 

Similar to AI Greedy Search and A* Algorithm Guide (20)

12 Greeddy Method
12 Greeddy Method12 Greeddy Method
12 Greeddy Method
 
Lec30
Lec30Lec30
Lec30
 
Greedy method1
Greedy method1Greedy method1
Greedy method1
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Fractional Knapsack Problem
Fractional Knapsack ProblemFractional Knapsack Problem
Fractional Knapsack Problem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Greedy
GreedyGreedy
Greedy
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
 
Optimization problems
Optimization problemsOptimization problems
Optimization problems
 
module3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfmodule3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdf
 
Knapsack algoritm
Knapsack algoritmKnapsack algoritm
Knapsack algoritm
 
Module 3_DAA (2).pptx
Module 3_DAA (2).pptxModule 3_DAA (2).pptx
Module 3_DAA (2).pptx
 
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
 
Mini project
Mini projectMini project
Mini project
 
Transportation technique
Transportation techniqueTransportation technique
Transportation technique
 
0/1Knapsack
0/1Knapsack0/1Knapsack
0/1Knapsack
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
 
Solving 0-1 knapsack problems based on amoeboid organism algorithm
Solving 0-1 knapsack problems based on amoeboid organism algorithmSolving 0-1 knapsack problems based on amoeboid organism algorithm
Solving 0-1 knapsack problems based on amoeboid organism algorithm
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
 

More from Learning Courses Online

More from Learning Courses Online (6)

Convolutional neural networks
Convolutional neural  networksConvolutional neural  networks
Convolutional neural networks
 
Heap Sort || Heapify Method || Build Max Heap Algorithm
Heap Sort || Heapify Method || Build Max Heap AlgorithmHeap Sort || Heapify Method || Build Max Heap Algorithm
Heap Sort || Heapify Method || Build Max Heap Algorithm
 
Introduction to Hash Tables | What is a HashTable in Algorithm
Introduction to Hash Tables | What is a HashTable in AlgorithmIntroduction to Hash Tables | What is a HashTable in Algorithm
Introduction to Hash Tables | What is a HashTable in Algorithm
 
Binary tree data structure
Binary tree data structureBinary tree data structure
Binary tree data structure
 
8 queens problem using ga
8 queens problem using ga8 queens problem using ga
8 queens problem using ga
 
Simple auto encoder
Simple auto encoderSimple auto encoder
Simple auto encoder
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

AI Greedy Search and A* Algorithm Guide

  • 2. Greedy search • Greedy search is a variation of the A* algorithm, where g(node) is set to zero, so that only h(node) is used to evaluate suitable paths. In this way, the algorithm always selects the path that has the lowest heuristic value or estimated distance (or cost) to the goal. • Greedy search is an example of a best-first strategy. • Greedy-search methods tend to be reasonably efficient, although in the worst case, like depth-first search, it may never find a solution at all.
  • 3. Knapsack problem • The knapsack problem is an interesting illustration of the use of greedy search algorithms and their pitfalls. The fractional knapsack problem can be expressed as follows: • A man is packing items into his knapsack. He wants to take the most valuable items he can, but there is a limit on how much weight he can fit in his knapsack. Each item has a weight wi and is profit pi. He can only fit a total weight of W in his knapsack.
  • 4. Knapsack problem • The items that he wants to take are things that can be broken up and still retain their value (like flour or milk), and he is The items that he wants to take are things that can be broken up and still retain their value (like flour or milk), and he is able to take fractions of items. Hence, the problem is called the fractional knapsack problem. • In solving this problem, a greedy-search algorithm provides the best solution. • The problem is solved by calculating the value per unit weight of each item: pi/wi, and then taking as much as he can carry of the item with the greatest value per unit weight. If he still has room, he moves on to the item with the next highest value per unit weight, and so on.
  • 5. Fractional Knapsack problem Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Items N = 7 Bag capacity M = 15
  • 6. Fractional Knapsack problem • Now we have a bag with capacity of 15. lets suppose 15 kg. • Now we want to transfer this bag from one location to another. • We are facing this problem in daily life. • Now problem is to filling of the objects in a container. • If you put all the objects in the bag with the capacity, there is no problem. • But the objects weight is more than the bag capacity, here the problem start.
  • 7. Fractional Knapsack problem • We should maximize the profit. • So this problem is optimization problem. • Can we apply the greedy method to solve this problem? • Yes, if it is suitable. • So what are the constraints here? • The bag capacity is 15, so all the objects which we want to transfer should be <= 15.
  • 8. Fractional Knapsack problem • For this problem we have many solutions. • The optimal result is to gain a maximum profit. • X = {x1, x2, x3, x4, x5, x6, x7} • We can say this problem is a fractional problem • 0 ≤ X ≤ 1
  • 9. Fractional Knapsack problem Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3 • Items n = 7 • Bag capacity m = 15
  • 10. Fractional Knapsack problem • Profit of each item per kg is • X1 = 5, x2=1.3, x3=3, x4=1, x5=6, x6=4.5, x7=3 Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3 Items n = 7 Bag capacity m = 15
  • 11. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3 Items n = 7 Bag capacity m = 15
  • 12. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 13. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 14. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 15. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 16. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 17. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 18. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 19. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 20. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 21. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 22. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 23. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3
  • 24. Fractional Knapsack problem • Now we select the items on the basis of their profit Objects 0 1 2 3 4 5 6 7 Profits p 10 5 15 7 6 18 3 Weights w 2 3 5 7 1 4 1 Max profit p/w 5 1.3 3 1 6 4.5 3 Items n = 7 Bag capacity m = 15
  • 25. A* algorithm for searching • Informed searching algorithm • A* Search algorithm is one of the best and popular technique used in path-finding and graph traversals. • Informally speaking, A* Search algorithms, unlike other traversal techniques, it has “brains”. What it means is that it is really a smart algorithm which separates it from the other conventional algorithms. • And it is also worth mentioning that many games and web-based maps use this algorithm to find the shortest path very efficiently (approximation).
  • 26. A* algorithm for searching • A* algorithms are similar to best-first search but use a somewhat more complex heuristic to select a path through the tree. The best- first algorithm always extends paths that involve moving to the node that appears to be closest to the goal, but it does not take into account the cost of the path to that node so far. • The A* algorithm operates in the same manner as best-first search but uses the following function to evaluate nodes: • f(n) = g(n) + h(n)
  • 27. A* algorithm for searching • g(n)--- actual cost from start node to n. • h(n)--- estimation cost from n to goal node.
  • 28. A* algorithm for searching • S is start node and G is goal node. • A* is an admissible algorithm which mean that it will give an optimal solution.
  • 29. A* algorithm for searching • We are taking a directed graph in this example. We also can take a tree to solve this problem. From S to B, 4 is actual value and in red color 12 is heuristic value.
  • 30. A* algorithm for searching • Explore S, SB, SC.
  • 31. A* algorithm for searching • We explore SCE, SCD, SBF, SBE
  • 32. A* algorithm for searching • We explore SCE, SCD, SBF, SBE
  • 33. A* algorithm for searching • We explore SCDEG
  • 34. A* algorithm for searching • Time complexity • T(C) = O(v+E) • In artificial intelligence point of view • O(b^d) • Where b is the branch factor, d is the depth.