Recursive Best-First Search (RBFS)

GATE Relevance: Medium

Prerequisites

🎯 Learning Objectives

  • Understand RBFS as a linear-space best-first search
  • Explain the f_limit mechanism and backed-up f-values
  • Write RBFS pseudocode
  • Compare RBFS with IDA*

1. Core Idea

RBFS mimics best-first search using only O(bd) space. It keeps track of the f-value of the best alternative path available from any ancestor. If the current node’s f-value exceeds this “f_limit,” RBFS unwinds back to explore the alternative, but stores the best f-value found in the forgotten subtree so it can return later if needed.

Key insight: When RBFS abandons a subtree, it backs up the best f-value from that subtree to the parent. This means RBFS remembers the “promise” of the forgotten subtree without storing it in memory.

2. Pseudocode

function RBFS(problem):
    return RBFS-SEARCH(problem, MAKE-NODE(problem.initial), ∞)

function RBFS-SEARCH(problem, node, f_limit):
    if GOAL-TEST(node.state):
        return SOLUTION(node), 0

    successors = EXPAND(node)
    if successors is empty:
        return FAILURE, ∞

    for each s in successors:
        s.f = max(g(s) + h(s), node.f)   // don't go below parent's f

    loop:
        best = successor with lowest f
        if best.f > f_limit:
            return FAILURE, best.f         // back up best f-value

        alternative = second-lowest f among successors
        result, best.f = RBFS-SEARCH(problem, best, min(f_limit, alternative))
        if result ≠ FAILURE:
            return result, 0
Key Detail: max(g(s)+h(s), node.f)

When generating successors, RBFS sets each child’s f-value to the maximum of its computed f and the parent’s f. This ensures f-values are non-decreasing along any path (important when the heuristic is not consistent).

3. Properties

PropertyRBFS
Complete?Yes (finite space with admissible h)
Optimal?Yes (with admissible h)
SpaceO(bd) — linear
TimeO(bd) worst case, but can be better than IDA* due to less re-expansion

4. RBFS vs IDA*

FeatureIDA*RBFS
Cutoff mechanismGlobal f-cost cutoffLocal f_limit per recursive call
Re-expansionRe-expands entire tree each iterationRe-expands only when switching between subtrees
Real-valued costsMay iterate many times (many distinct f-values)Handles better — switches at exact f-value thresholds
Backed-up knowledgeNone — forgets everything between iterationsRemembers best f-value of abandoned subtrees
Complexity of codeSimplerMore complex (tracked f-values)

5. Worked Examples

Example 1: RBFS Walkthrough
Graph: S→A (cost 1), S→B (cost 1)
       A→G (cost 3), B→C (cost 1), C→G (cost 1)
h: h(S)=2, h(A)=3, h(B)=2, h(C)=1, h(G)=0

Call RBFS(S, f_limit=∞)

  1. Expand S: successors A (f=1+3=4), B (f=1+2=3). Max with parent f(S)=2: A.f=max(4,2)=4, B.f=max(3,2)=3.
  2. best = B (f=3), alternative = A (f=4). Call RBFS(B, f_limit=min(∞,4)=4).
  3. Expand B: successor C (f=2+1=3). Max with parent f(B)=3: C.f=max(3,3)=3.
  4. best = C (f=3), no alternative → alternative=∞. Call RBFS(C, f_limit=min(4,∞)=4).
  5. Expand C: successor G (f=3+0=3). Max with parent f(C)=3: G.f=max(3,3)=3.
  6. best = G (f=3 ≤ 4). Goal test on G: SUCCESS! Path S→B→C→G, cost=3.

RBFS found the optimal path without ever exploring A’s subtree.

Example 2: RBFS with Subtree Switching
Graph: S→A (cost 1), S→B (cost 2)
       A→D (cost 3), B→G (cost 1)
h: h(S)=2, h(A)=1, h(B)=1, h(D)=5, h(G)=0

Call RBFS(S, f_limit=∞)

  1. Expand S: A (f=1+1=2), B (f=2+1=3). Parent f(S)=2: A.f=max(2,2)=2, B.f=max(3,2)=3.
  2. best = A (f=2), alternative = B (f=3). Call RBFS(A, f_limit=min(∞,3)=3).
  3. Expand A: D (f=4+5=9). Max with parent f(A)=2: D.f=max(9,2)=9.
  4. best=D (f=9 > f_limit=3). Return FAILURE, back up f=9 to A: A.f ← 9.
  5. Back in S: now A.f=9, B.f=3. best=B. Call RBFS(B, f_limit=min(∞,9)=9).
  6. Expand B: G (f=3+0=3). Max with parent f(B)=3: G.f=max(3,3)=3.
  7. best=G (f=3 ≤ 9). Goal! Path S→B→G, cost=3.

RBFS explored A first (lower f), discovered it was unpromising (D has f=9), backed up f=9 to A, then switched to B and found the goal.

Summary

  • RBFS uses O(bd) space like IDA*, but is generally more efficient in time.
  • Backed-up f-values let RBFS “remember” abandoned subtrees’ promise.
  • Handles real-valued costs better than IDA*.
  • Still suffers from excessive re-generation of nodes (time cost for space saving).
  • Optimal and complete with admissible heuristic.