0% found this document useful (0 votes)
12 views16 pages

AI3ANS

The document discusses various search algorithms including Hill Climbing, Min-Max, Alpha-Beta Pruning, Breadth-First Search (BFS), Depth-First Search (DFS), and Depth Limited Search (DLS). It outlines the definitions, characteristics, steps, advantages, disadvantages, and solutions to limitations for each algorithm. The content provides a comprehensive overview of these algorithms and their applications in problem-solving and decision-making contexts.

Uploaded by

122shreya2080
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

AI3ANS

The document discusses various search algorithms including Hill Climbing, Min-Max, Alpha-Beta Pruning, Breadth-First Search (BFS), Depth-First Search (DFS), and Depth Limited Search (DLS). It outlines the definitions, characteristics, steps, advantages, disadvantages, and solutions to limitations for each algorithm. The content provides a comprehensive overview of these algorithms and their applications in problem-solving and decision-making contexts.

Uploaded by

122shreya2080
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Q. Write the Short notes on hill Climbing Algorithm.

Definition:

●​ Hill Climbing is a local search algorithm used to find an optimal solution by iteratively
moving towards higher-valued states.

Characteristics:

●​ Follows a greedy approach (always moves to the best neighbor).


●​ No backtracking (does not revisit past states).
●​ Uses heuristic evaluations to measure solution quality.

Steps of Hill Climbing:

1.​ Initial State: Start with a random solution.


2.​ Neighboring States: Identify neighbors by making small changes.
3.​ Move to Neighbor: If a neighbor has a better value, move to it.
4.​ Termination: Stop when no better neighbor exists (local maximum).

Types of Hill Climbing:

●​ Simple Hill Climbing: Moves to the first better solution found.


●​ Steepest-Ascent Hill Climbing: Evaluates all neighbors and moves to the best one.
●​ Stochastic Hill Climbing: Randomly selects a neighbor based on probability.

Problems in Hill Climbing:

●​ Local Maximum: Algorithm gets stuck at a peak that is not the best.
●​ Plateau: A flat region where all neighbors have the same value.
●​ Ridges: A narrow path where single moves cannot improve the solution.

Solutions to Problems:

●​ Random restarts: Restart from different points to escape local maxima.


●​ Simulated Annealing: Allows some downward moves to escape traps.
●​ Use of memory: Store promising paths for backtracking.

Advantages:

●​ Works well in large search spaces.


●​ Requires less memory.
●​ Finds good solutions quickly.

Disadvantages:

●​ Can get stuck in local optima.


●​ No guarantee of finding the global optimal solution.
●​ Depends on the quality of heuristic function.
Q. What are the limitations of Hill climbing algorithm? How can we solve them.

Limitations of Hill Climbing Algorithm & Their Solutions (5 Marks)

1.​ Local Maximum


○​ The algorithm stops at a peak that is better than its neighbors but not the best
solution.
○​ It cannot explore beyond this point due to its greedy nature.

○​
○​
○​ ​
Solutions:
○​ Use backtracking to explore other paths.
○​ Apply random restarts to start from different initial points.
2.​ Plateau
○​ A flat area where all neighboring states have the same value, making it hard
to decide the next move.
○​ The algorithm may keep moving randomly without improving the solution.
○​

○​ ​
Solutions:
○​ Take random big or small steps to escape.
○​ Use stochastic hill climbing, which selects random moves to avoid getting
stuck.
3.​ Ridges
○​ A narrow high area where single moves do not improve the solution.
○​ The algorithm fails to move forward because each step is not steep enough.
○​
○​
○​ ​
Solutions:
○​ Use multi-directional moves to navigate ridges effectively.
○​ Apply bidirectional search to explore both forward and backward paths.

Q. What is Min-Max Search ? Explain with Example.

Definition

●​ Min-Max is an algorithm used in game playing and decision-making.


●​ It helps find the best move by assuming both players play optimally.

Working Principle

●​ One player (Max) tries to maximize the score (best outcome).


●​ The other player (Min) tries to minimize the score (worst outcome for Max).

Steps of Min-Max Algorithm

●​ Generate the game tree with all possible moves.


●​ Assign utility values to terminal states (win, lose, draw).
●​ Backpropagate values: Max picks the highest value, Min picks the lowest.
●​ Choose the best move based on the root node's value.

Example Use Cases

●​ Used in games like Chess, Tic-Tac-Toe, and Checkers.


●​ Helps AI make decisions in competitive environments.

Advantages

●​ Ensures the best possible move if both players play optimally.


●​ Provides a clear strategy for decision-making in games.
Q. Explain Alpha Beta pruning with example.
Alpha-Beta Pruning is an optimization technique used to improve the performance of the
Minimax algorithm, which is commonly applied in two-player games such as Chess,
Tic-Tac-Toe, and Connect Four.

Purpose of Alpha-Beta Pruning:

The Minimax algorithm checks all possible moves in a game tree to find the best one.
However, this is very time-consuming.​
Alpha-Beta Pruning helps by eliminating unnecessary branches in the tree which do not
affect the final result.​
This makes the algorithm faster and more efficient.

Important Terms:

1.​ Alpha (α):​


The best (maximum) value that the Maximizer (e.g., Player X) can guarantee at
that point.​

2.​ Beta (β):​


The best (minimum) value that the Minimizer (e.g., Player O) can guarantee at that
point.​

3.​ Pruning:​
Skipping the rest of the branches when it is clear they won’t influence the final
decision.​
This happens when α ≥ β.​

Working of Alpha-Beta Pruning (Step-by-Step):

1.​ Start with α = -∞ and β = +∞.​

2.​ Traverse the game tree using depth-first search.​

3.​ At each node:​

○​ If it's a Max node, update α with the highest value found so far.​

○​ If it's a Min node, update β with the lowest value found so far.​
4.​ If at any point α ≥ β, we stop exploring further branches (prune the rest).​

5.​ Continue this process until all necessary nodes are evaluated.​
Advantages of Alpha-Beta Pruning:

●​ Reduces the number of nodes evaluated.​


●​ Makes the Minimax algorithm much faster.​

●​ Allows deeper exploration in the same amount of time.​

●​ Does not affect the accuracy or final decision of the Minimax algorithm.​

Conclusion:

Alpha-Beta Pruning is a powerful technique used in game-playing AI.​


It improves the efficiency of the Minimax algorithm by pruning branches that cannot
influence the final decision.​
This makes decision-making faster without compromising on the result.

Q. BFS

Breadth-First Search (BFS) is an algorithm used for searching a graph or tree. It explores all
the nodes at the present depth (level) before moving on to the nodes at the next depth level.

Working of BFS:

●​ Start from the root node (or starting node).​

●​ Visit the starting node and put it into a Queue (First-In-First-Out, FIFO).​

●​ Explore all the neighbor nodes of the current node.​

●​ After visiting all neighbors, move to their neighbors.​

●​ Continue this process until the goal node is found or all nodes are explored.​

Important Points about BFS:

●​ BFS uses a Queue data structure.​

●​ It explores nodes level by level (breadth-wise).​


●​ BFS guarantees the shortest path in an unweighted graph.​

Advantages of BFS:

●​ Complete: Always finds a solution if one exists.​

●​ Optimal: Finds the shortest path in an unweighted graph.​

●​ Simple: Easy to understand and implement.​

Disadvantages of BFS:

●​ High Memory Requirement: Needs to store all nodes at a particular level.​

●​ Slow for Large Graphs: Can take a lot of time and space if the graph is large.​

Performance Analysis:

Property Value

Completeness Yes (will find a solution if it exists).

Optimality Yes (finds shortest path in unweighted


graphs).

Time Complexity O(b^d)

Space O(b^d)
Complexity

Where:

●​ b = branching factor (average number of children per node),​

●​ d = depth of the shallowest goal node.​


Conclusion:​
BFS is a simple and powerful algorithm that finds the shortest path but uses a lot of
memory. It is best suited for problems where the solution is located near the starting node.
Q. DFS.

Definition:​
Depth-First Search (DFS) is a searching algorithm that explores as far as possible along
each branch before backtracking. It goes deep into one path before trying other paths.

Working of DFS:

●​ Start from the root node (or starting node).​

●​ Visit the node and mark it as visited.​

●​ Move to one of its neighbors (child nodes) and repeat the process.​

●​ If there are no more unvisited neighbors, backtrack to the previous node and
continue the search.​

●​ Repeat this process until the goal node is found or all nodes are explored.​

Important Points about DFS:

●​ DFS uses a Stack data structure (Last-In-First-Out, LIFO).​


(It can also be implemented using recursion.)​

●​ DFS explores a path completely before moving to another path.​

●​ It may not always find the shortest path.​

Advantages of DFS:

●​ Memory Efficient: Requires less memory compared to BFS.​

●​ Simple Implementation: Easy to implement using recursion.​

●​ Useful for Solving Puzzles: Good for problems like mazes, puzzles, etc.​

Disadvantages of DFS:
●​ Not Complete: May get stuck in infinite loops if the graph is infinite.​

●​ Not Optimal: Does not guarantee the shortest path.​

●​ May Miss Solutions: If the solution is far or in a different branch.​

Performance Analysis:

Property Value

Completeness No (may miss solutions in infinite graphs).

Optimality No (may not find the shortest path).

Time Complexity O(b^m)

Space O(bm)
Complexity

Where:

●​ b = branching factor (average number of children per node),​

●​ m = maximum depth of the search tree.​

Conclusion:​
DFS is a deep exploring technique useful for memory-limited situations but may not always
find the best or shortest solution. It is best for exploring all possible solutions or searching in
very large spaces where memory is a concern.

Q. DLS

Definition:​
Depth Limited Search (DLS) is a modified version of Depth-First Search (DFS) where a limit
is set on how deep the search can go.​
It helps to avoid infinite loops by restricting the depth of exploration.

Working of DLS:
●​ Start from the root node (starting point).​

●​ Explore nodes like DFS, but only up to a fixed depth limit.​

●​ If the goal is found within the depth limit, return success.​

●​ If the depth limit is reached without finding the goal, cut off the search for that path.​

●​ If all paths are cut off or fail, return failure.​

Important Points about DLS:

●​ Depth Limit is a fixed number that stops the search after a certain number of steps.​

●​ Nodes deeper than the limit are not explored.​

●​ DLS helps solve the infinite path problem in DFS.​

Advantages of DLS:

●​ Prevents Infinite Loops: Stops search after a certain depth.​

●​ Memory Efficient: Similar to DFS, uses less memory.​

●​ Useful when Depth is Known: Best when we have an idea about solution depth.​

Disadvantages of DLS:

●​ May Miss Solutions: If the solution lies deeper than the limit.​

●​ Choosing Depth Limit is Hard: Setting a wrong limit can lead to failure.​

●​ Not Optimal: Does not guarantee the shortest path.​

Performance Analysis:

Property Value
Completeness Only if the solution is within depth limit.

Optimality No

Time Complexity O(b^l)

Space O(b × l)
Complexity

Where:

●​ b = branching factor,​

●​ l = depth limit.​

Conclusion:​
Depth Limited Search (DLS) is an improved version of DFS that stops the search beyond a
specific depth, making it safer against infinite paths but requiring careful selection of the
depth limit.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy