Depth First Search With Bounded Memory - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Depth First Search With Bounded Memory

Description:

Start at the root of a virtual tree. Vertices represent puzzle states. ... Height is bounded by the number of binary elements (9x9x9 in regular Sudoku) ... – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 14
Provided by: stude6
Category:

less

Transcript and Presenter's Notes

Title: Depth First Search With Bounded Memory


1
Depth First Search With Bounded Memory
  • Brian Boodman

2
Depth First Search
  • Start at the root of a virtual tree.
  • Vertices represent puzzle states.
  • Root of tree is initial state.
  • Edges represent steps in a puzzle.
  • Vertices have n children, with n being the number
    of different possible steps.

3
Search
  • Solution

4
Pruning and Efficiency
  • Choose decision points where branches are
    invalid. If all branches are invalid, then
    backtrack. If only one branch is valid, ) branch
    is invalid (i.e. is clearly wrong) . If such
    decisions are always possible, searching reduces
    to non-searching.

4
3
4
2
3
4
1
4
2
5
Example Mini Sudoku
Memory usage for search O(HeightNode)
6
Alternative Difference Edges
1
2
4
3
Memory usage for search O(HeightDiff)
7
Binary tree
  • Rather than splitting a tree into a child for
    each of the M possible values, an alternative is
    to use a binary tree, splitting a tree along,
    the value is N and the value is not N for any
    given split. This will reduce the branching
    factor of the tree but will increase the height.
  • Binary trees generated with this method use more
    nodes. Most can be trivially pruned, however.
  • Advantage but most such nodes can be trivially
    pruned if the value is N, the value is not
    1,2,3,N-1,N1,N2,)
  • Backtracking is easy. If one direction is wrong,
    there is only one other choice.

8
Binary Example
9
Binary Example with pruning
10
An alternative method to store the tree.
  • It is possible to store the edges themselves
    within state.
  • Use a binary tree for easy backtracking.
  • Store the current height of the tree in the node.
    Note that pruning does not increase the height
    of the tree, so multiple elements in the state
    may have the same height.
  • If backtracking, the flip the state of the node
    that is of the current height (remove any pruning
    information), and drop the height by 1.

11
Demo
  • Nurikabe Demo (samplet, sample).
  • Nurikabe source, documentation, and presentation
    available upon request.

12
Bounded Memory
  • Since the tree is stored in the with the binary
    states and such storage uses constant memory for
    this storage (only tree height is explicitely
    stored), memory is bounded.
  • This is awesome!
  • All depth first searches have this feature.
  • Recall A depth first search only needs
    O(HeightDiff). Height is bounded by the number
    of binary elements (9x9x9 in regular Sudoku).

13
So whats the point?
  • This storage method is theoretically exactly the
    same as using a traditional storage mechanism
    (using difference edges). It has the same
    space/time complexities.
  • It may be less work to code.
  • All memory allocation occurs in advance.
  • Visualizing the complete graph all at once is
    easier since the heights are embedded in the
    state.
Write a Comment
User Comments (0)
About PowerShow.com