AI3ANS
AI3ANS
Definition:
● Hill Climbing is a local search algorithm used to find an optimal solution by iteratively
moving towards higher-valued states.
Characteristics:
● 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:
Advantages:
Disadvantages:
○
○
○
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.
Definition
Working Principle
Advantages
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:
3. Pruning:
Skipping the rest of the branches when it is clear they won’t influence the final
decision.
This happens when α ≥ β.
○ 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:
● Does not affect the accuracy or final decision of the Minimax algorithm.
Conclusion:
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:
● Visit the starting node and put it into a Queue (First-In-First-Out, FIFO).
● Continue this process until the goal node is found or all nodes are explored.
Advantages of BFS:
Disadvantages of BFS:
● Slow for Large Graphs: Can take a lot of time and space if the graph is large.
Performance Analysis:
Property Value
Space O(b^d)
Complexity
Where:
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:
● 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.
Advantages of DFS:
● 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.
Performance Analysis:
Property Value
Space O(bm)
Complexity
Where:
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).
● If the depth limit is reached without finding the goal, cut off the search for that path.
● Depth Limit is a fixed number that stops the search after a certain number of steps.
Advantages of DLS:
● 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.
Performance Analysis:
Property Value
Completeness Only if the solution is within depth limit.
Optimality No
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.