liveBook · Manning

Pruning

As explained in Advanced Algorithms and Data Structures

Pruning is the elimination of search-tree branches that cannot contain a valid or better candidate.

Pruning eliminates branches that cannot contain a valid or better candidate. It reduces unnecessary work during search and can reclaim storage after deletion, but aggressive pruning may trade accuracy for speed. section 6.2.4 section 10.4.3

Apply pruning differently according to the structure and objective:

  • During trie deletion, unmark the key node, backtrack along the searched path, and remove nodes that become worthless leaves. Stop at a key node or an intermediate node with remaining children. section 6.2.4
  • During R-tree point search, traverse only rectangles that can contain the query point. For nearest-neighbor search, discard branches whose closest possible distance exceeds the current minimum. section 10.2.4
  • During approximate nearest-neighbor search, use a more aggressive criterion to visit fewer branches, accepting that the returned result may not be perfectly accurate. section 10.4.3

Removing a key from a trie

After deleting “anti,” its terminal node becomes a worthless leaf, so backtracking removes the edge for “i.” The node for “ant” then also becomes removable. Pruning stops when it reaches a parent that stores a key or still has another child. section 6.2.4

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains recursive trie pruning and distance-based R-tree decisions, then stops short of detailed R-tree nearest-neighbor implementation.
Examples
Demonstrates pruning through trie deletion, R-tree point search, and approximate nearest-neighbor traversal.
What it assumes
Assumes familiarity with tree traversal, trie nodes, spatial bounds, distances, and nearest-neighbor search.
What you can do after
Apply it via trie deletion and R-tree search to reduce branches, reclaim dangling nodes, or control approximate-query accuracy.
How it connects
Connects tries, search trees, R-trees, nearest-neighbor search, approximate similarity search, and early termination.

Also explained in

Compare how 7 books explain pruning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.