UNSW Sydney · FACULTY OF COMPUTER SCIENCE

COMP9414 Chap.4 Search Strategy and Heuristic Choice

- one subject, every graph, every model, every mark
6 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 5 · COMP9414

Search Strategy and Heuristic Choice

DFS, BFS, UCS and A* share a search loop but assign different meanings to the best frontier candidate. This chapter derives their guarantees from stack, queue, cumulative-cost and estimated-total-cost priorities. It works an original A* trace with improved paths, distinguishes edge count from weighted cost, and turns admissibility into a numerical check rather than a memorised slogan.

In this chapter

What this chapter covers

  • 01

    Depth-first search with a LIFO frontier

  • 02

    Breadth-first search with a FIFO frontier

  • 03

    Uniform-cost search ordered by cumulative g

  • 04

    Greedy search ordered by heuristic h

  • 05

    A* search ordered by f equal to g plus h

  • 06

    Admissibility as an optimistic remaining-cost estimate

Worked example · free

A* with a goal-cost improvement

Q [4 marks]. AskSia-authored practice. The mark allocation shown here is not an official university marking scheme. On the graph in the guide, compute g, h and f after each expansion and return the cheapest goal path. AskSia practice weighting: 4 marks.
The frontier rule determines what “best next” means.The frontier rule determines what “best next” means. DFS prefers depth, BFS prefers fewest actions so far, UCS minimises cumulative path cost g, and A* minimises estimated total cost g+h; the guarantee printed in each lane depends on the stated cost or heuristic condition. DFSBFSUCSA* deepestLIFO stackno pathoptimality shallowestFIFO queueoptimal whenunit cost lowest gpriority queuepositive-costoptimal path lowest g+hpriority queueadmissible hoptimal path
The frontier rule determines what “best next” means. DFS prefers depth, BFS prefers fewest actions so far, UCS minimises cumulative path cost g, and A* minimises estimated total cost g+h; the guarantee printed in each lane depends on the stated cost or heuristic condition.
  • +1Expand S and record separate g, h and f values for A and B before applying the tie rule.
  • +1Expand A, giving C priority 5 and a direct goal route with cost and priority 8.
  • +1Expand C and improve the goal to g=6 and f=6; reject a later worse route to C.
  • +1Return S-A-C-G with actual cost 6 and justify the heuristic through the admissibility comparison.
The route S-A-C-G costs 6. The heuristic affects expansion order, while the returned route cost is the sum of actual edges and equals g at the goal.
Sia tip — Never add heuristic values along the path. Use h for ordering, use g for improvements, and use actual edges for the reported cost.
Glossary

Key terms

Depth-first search
A strategy that expands a deepest frontier path first through last-in, first-out order.
Breadth-first search
A strategy that expands shallowest frontier paths first through first-in, first-out order.
Uniform-cost search
A strategy that expands the frontier path with the lowest cumulative cost g.
A* search
A strategy that expands the lowest estimated total cost f, defined as g plus h.
Admissibility
The property that a heuristic never overestimates the true cheapest remaining cost.
FAQ

Search Strategy and Heuristic Choice FAQ

Why can BFS return an expensive route?

BFS minimises the number of edges, not the sum of arbitrary weights. A two-edge route can cost more than a three-edge route. Its lowest-cost guarantee applies when every action has the same cost, so state the cost model before interpreting optimality.

Why does setting h to zero recover UCS?

A* orders by f=g+h. When h is zero for every node, f equals g, so the priority queue makes the same cumulative-cost choice as uniform-cost search. The result is admissible but supplies no goal-directed guidance.

How do I test whether h is admissible?

For each node where the true cheapest remaining cost is available, compare the estimate directly. The heuristic must lie between zero and that true cost and should be zero at a goal. One overestimate removes the course optimality condition.

Study strategy

Exam move

Use one small weighted graph for four passes. Trace DFS and BFS first to make stack and queue order automatic, then calculate every route cost and trace UCS. Add a heuristic table only after the UCS trace is correct. For A*, maintain columns for node, parent, g, h and f; replace a parent only when the new g is smaller.

After the trace, solve the remaining-cost problem exactly and compare each h with the true value to audit admissibility. Practise explaining why the same graph can yield a shallow but expensive BFS route and a deeper but cheaper UCS route. Finish every algorithm comparison with the condition supporting completeness or optimality. This converts property lists into reasoning that can be reconstructed under exam pressure.

Build a guarantee card for each method with three rows: selection rule, assumption and conclusion. Shuffle the cards and reconstruct the missing row rather than memorising a paragraph. Next perturb one edge weight while leaving graph depth unchanged and predict which algorithms may change their returned route.

Set h to zero to verify the UCS equivalence, then raise one heuristic above the exact remaining cost and identify the lost assurance without claiming that failure is inevitable. During coding practice, print stale priority-queue entries and explain why the best-cost table prevents them from corrupting the result. Compare the number of expansions only after confirming that goal timing and tie-breaking match.

End each session by recomputing the final cost directly from edges and checking that it equals g at the goal. These habits isolate ordering, bookkeeping and proof conditions so one error does not contaminate every conclusion. Maintain a separate uncertainty ledger for every trace.

Record the neighbour order, goal-test timing, duplicate policy and tie rule before the first expansion; if an answer differs from a reference, compare those conventions before changing the algorithm. Then diagnose one deliberately inconsistent heuristic by locating an edge whose local estimate drop exceeds its cost.

Reopen the affected node in a graph-search trace and state why a closed-once implementation could otherwise miss the cheaper route.

Working through Search Strategy and Heuristic Choice in COMP9414? Sia is AskSia’s AI Computer Science tutor — ask any COMP9414 Search Strategy and Heuristic Choice question and get a clear, step-by-step explanation grounded in how COMP9414 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 103 of your UNSW Sydney subjects - and 1,000+ Bibles across every Australian university.
Sia - your COMP9414 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works
COMP9414 · Artificial Intelligence - independent study guide on the AskSia Library. More UNSW Sydney subjects · Microeconomics across all universities