AI UNIT 2
AI UNIT 2
Kaviyaraj R
In the mystical Kingdom of Data, a priceless treasure
has been hidden. However, the kingdom is divided
into four unique regions each organized in its own
special way:
• The Stacked Tower (stacks) where items are piled
one on top of the other,
• The Queueing Quay (queues) where everyone lines
The Story up in order,
• The Tree of Knowledge (trees) that branches out
like a family tree, and
• The sprawling city of Graphopolis (graphs) with
complex interconnections.
Your mission is to use the unique properties of each
region and the power of search algorithms to
uncover clues and ultimately find the treasure.
Assign Regions:
Group • Groups 1: Stacked Tower (DFS simulation)
• Groups 2:Queueing Quay (BFS simulation)
Formation & • Groups 3: Tree of Knowledge (Tree Traversals /
Role Binary Search Simulation)
Where Used
▪ Routing in graphs with varying step costs
(e.g., different terrain costs).
▪ Any unweighted problem if you want a cost-based
approach (although BFS is simpler if all edges = 1).
Depth-First Search (DFS)
▪ An uninformed search that always expands the deepest node in the frontier first.
▪ Uses a stack (LIFO) or recursion.
▪ May find a solution quickly if it is “down” one path but may also get stuck exploring long or irrelevant
branches.
▪ Not guaranteed the shortest or minimal-cost path.
▪ Low memory usage (only tracks path + visited).
▪ Can be fast if the goal is along the first branch explored.
▪ No guarantee of finding a short or optimal path.
▪ Potentially visits deep irrelevant branches.
Where Used
▪ Depth-based puzzle solving, or if you only need any
solution quickly and space is limited.
▪ Often part of other algorithms (e.g., Depth-Limited, ID-DFS).
▪ A variation of DFS that cuts off exploring deeper than a
specified depth limit.
▪ If the goal is not found within that depth, the search fails for
that limit.
▪ Avoids DFS’s risk of going infinitely deep in certain graphs.
Depth- ▪ If the goal is deeper than the limit, DLS won’t find it.
▪ Controls the maximum exploration depth.
Limited ▪ Can reduce time/memory if you suspect the goal is within a
certain depth.
Search (DLS) ▪ May fail if the goal is below the cutoff depth.
▪ Not guaranteed to find the shortest path or any solution if
limit is too small.
Where Used
▪ When you have a known or estimated depth limit.
▪ As a component of Iterative Deepening Search.
Informed Search
▪ A naive, uninformed approach that tries random paths
from the start to see if you eventually reach the goal.
▪ Often repeated multiple times or up to a max attempts
limit.
▪ No systematic expansion or cost consideration.
Generate & ▪ May succeed by luck, but can also wander or cycle.
(Greedy) is good.
▪ Can be tricked by obstacles or ignoring real costs.
▪ Not guaranteed the shortest route in actual cost or steps.
Where Used
▪ Large state spaces where a heuristic can guide expansions,
but optimal cost is not crucial.
▪ Approximate or “greedy” solutions.
▪ An informed search that uses f(n)=g(n)+h(n), where g(n) =
cost so far, h(n) = heuristic to the goal.
▪ With an admissible heuristic (never overestimates), A*
finds the optimal path in cost.
▪ Typically fewer expansions than UCS because it prunes
irrelevant routes.
▪ The quality of the heuristic strongly influences
performance.
A* Search ▪ Optimal if the heuristic is admissible and consistent.
▪ Usually faster expansions than UCS.
▪ Requires a good heuristic to be efficient.
▪ If the heuristic is bad or overestimates, you can lose
optimality or slow down.
Where Used
▪ Common in games, robotics, map routing with good
heuristics (e.g., Euclidean or Manhattan distance in grids).