Practice Discrete Math

Algorithms / Recursion Tree Pruning

Least You Need to Know: Recursion Trees, Feasibility Checks, and Pruning

A recursion tree shows the search branches a backtracking algorithm may explore. **Pruning** means cutting off branches as soon as a partial state can no longer lead to a valid or useful solution.

جو کم از کم جاننا ضروری ہے

اہم علامتیں

branch one recursive choice from the current partial state
prune stop exploring a branch that cannot help
feasibility check test whether the current partial state can still lead to a solution

مختصر حل شدہ مثال

  • Imagine placing queens row by row.
  • If a partial placement already has two queens attacking each other, no extension of that placement can become valid.
  • So you stop there instead of exploring the rest of that subtree.
  • That saved work is the whole point of pruning.

عام غلطیاں

اس قسم کے سوال کو کیسے پہچانیں

Next recommended lesson

Continue through this topic with Least You Need to Know: Rolling Hashes and Substring Fingerprints.

Least You Need to Know: Rolling Hashes and Substring Fingerprints

Related lessons

Keep going with nearby lessons in the same topic.

More ways to explore

مشق شروع کریں