State Space Representation

GATE Relevance: High

Prerequisites

🎯 Learning Objectives

  • Differentiate between a state space graph and a search tree
  • Describe the node data structure (state, parent, action, path-cost, depth)
  • Understand the frontier (open list) and explored set (closed list)
  • Compare tree search vs. graph search algorithms
  • Trace node expansion order on example problems

1. State Space Graph

The state space graph is a mathematical representation of a search problem. Each node represents a unique state, and each directed edge represents an action that takes the agent from one state to another. The state space graph is typically too large to build in memory (the 8-puzzle has 181,440 states), but it is a useful conceptual tool.

Key Property

In a state space graph, each state appears exactly once. There are no duplicate nodes. If state A can reach state B through two different action sequences, there are still only two nodes (A and B) but possibly multiple edges.

2. Search Tree

The search tree is what the search algorithm actually builds during execution. It is generated on-the-fly by “expanding” states. Unlike the state space graph, the search tree can have repeated states—the same state may appear at multiple nodes in the tree.

FeatureState Space GraphSearch Tree
NodesOne node per unique stateCan have many nodes for same state
SizeFixed (= number of states)Can be infinite (even for finite state spaces)
MemoryUsually too large to storeBuilt incrementally
CyclesMay contain cyclesCan contain repeated states (not cycles as a tree)
RootN/A (it’s a graph)The initial state
⚠ Critical GATE Distinction

In a graph with cycles, the search tree (without cycle detection) can be infinite even if the state space is finite. For example, if A→B and B→A, the tree can alternate A→B→A→B→… forever. This is why graph search (with an explored set) is essential.

3. Node Data Structure

Each node n in the search tree stores five pieces of information:

Node = (STATE, PARENT, ACTION, PATH-COST, DEPTH)
  • n.STATE: The state in the state space to which the node corresponds.
  • n.PARENT: The node that generated this node (allows path reconstruction).
  • n.ACTION: The action applied to the parent’s state to generate this node.
  • n.PATH-COST: g(n) = the cost of the path from the initial state to this node. Computed as: n.PARENT.PATH-COST + c(parent.STATE, n.ACTION, n.STATE).
  • n.DEPTH: The number of steps from the root. root.DEPTH = 0.
Node ≠ State

A state is a representation of a physical configuration. A node is a data structure that is part of the search tree. Two different nodes can contain the same state. The node also knows how it was reached (parent pointer + action).

4. Expanding Nodes

Expanding a node means generating all successor nodes by applying each legal action to the node’s state. For example, expanding the node for Arad in the Romania problem generates child nodes for Zerind, Sibiu, and Timisoara.

function EXPAND(problem, node):
    s = node.STATE
    for each action in problem.ACTIONS(s):
        s' = problem.RESULT(s, action)
        cost = node.PATH-COST + problem.STEP-COST(s, action, s')
        yield Node(STATE=s', PARENT=node, ACTION=action, PATH-COST=cost, DEPTH=node.DEPTH+1)

5. Frontier and Explored Set

Frontier (Open List)

The frontier is the set of all leaf nodes in the search tree that have been generated but not yet expanded. It represents the boundary between explored and unexplored regions. The data structure used for the frontier determines the search strategy:

  • FIFO queue → Breadth-First Search
  • LIFO stack → Depth-First Search
  • Priority queue (min path cost) → Uniform-Cost Search
Explored Set (Closed List)

The explored set stores every state that has been expanded. When a new node is generated, we check if its state is in the explored set. If so, we discard the node (it’s a duplicate). This prevents infinite loops in cyclic state spaces.

7. Time and Space Measurement Criteria

Search algorithms are evaluated using four criteria defined in terms of:

  • b — branching factor (maximum number of successors of any node)
  • d — depth of the shallowest goal node
  • m — maximum depth of the search tree (may be ∞)
Four Evaluation Criteria
  1. Completeness: Is the algorithm guaranteed to find a solution if one exists?
  2. Optimality: Does it find the least-cost solution?
  3. Time complexity: How many nodes are generated/expanded?
  4. Space complexity: How many nodes are stored in memory at peak?

8. Worked Examples

Example 1: Node Expansion on a Simple Graph

Consider the graph: S→A (cost 1), S→B (cost 4), A→B (cost 2), A→G (cost 5), B→G (cost 1). Start: S, Goal: G.

BFS expansion order (FIFO):

  1. Expand S → frontier: [A, B]
  2. Expand A → frontier: [B, B′, G] (B′ is B via A)
  3. Expand B → frontier: [B′, G, G′]
  4. Expand B′ → frontier: [G, G′, G′′]
  5. Expand G → GOAL! Path: S→A→G, cost=6

With graph search, at step 3, B′ would be discarded (B already explored), and only one G is in the frontier.

Example 2: Tree Search Infinite Loop

Graph: A↔B. Starting at A with goal at C (which doesn’t exist).

Tree search: A→B→A→B→A→… (infinite loop, never terminates).

Graph search: Expand A (explored={A}), generate B. Expand B (explored={A,B}), generate A—but A is in explored, so discard. Frontier empty → return FAILURE.

Example 3: Search Tree Size vs. Graph Size

Consider a 4×4 grid (16 states). Each cell connects to its neighbors. The state space graph has 16 nodes and ~24 edges. But the search tree from the top-left corner, without cycle detection, can grow to thousands of nodes because the agent can revisit cells via different paths.

Summary

  • The state space graph has one node per state; the search tree can have many nodes per state.
  • A node stores: STATE, PARENT, ACTION, PATH-COST, DEPTH.
  • The frontier (open list) holds generated-but-unexpanded nodes; the explored set (closed list) prevents revisiting.
  • Tree search can loop forever; graph search avoids this with the explored set.
  • Search algorithms are measured by completeness, optimality, time complexity, space complexity in terms of b, d, m.

References

  • Russell, S. & Norvig, P. Artificial Intelligence: A Modern Approach, Chapter 3.3.