Question: I am new to iphone development.I want insert my xml parsed contents into a sqlite3 database and retrieve it and display it in a tableView.I am able to parse and directly display the contents using nsxml parser.Please help me how to proceed to store the contents in a database and retrieve it .Thanks.

Answer: 
This is the typical problem where you should use the trie data structure: <http://en.wikipedia.org/wiki/Trie>

Once you have a dictionary with all the target words you go through each position of your two dimension array and call a recursive function that expands all 8 ways. Something along the lines of.

```
void Explore(TwoDimArray puzzle, Point2D currentCell, string currentMatch, List<string> foundSolutions);

```

You stop recursiveness if:  

- You find a match.  

- The currentMatch + currentCell's character no longer constitute a possible match.  

- The currentCell position is no longer inside the puzzle area.
Do NOT use a 2 dimensional array for the puzzle. For an NxM word search, use an array of (N+2)\*(M+2). Put padding of 1 character all the way around your puzzle. So the example becomes:

```

......
.BXXD.
.AXEX.
.TRXX.
.FXXX.
......

```

Where the periods are the padding and all of this is really a 1d array.

Calling the width of the new grid the row span (S), you can now create an array of 8 direction "vectors" D=[ -S-1, -S, -S+1, -1, 1, S-1, S, S+1 ]. Using this, you can look from any position in the grid Puzzle[position] to its neighbor in any direction by using Puzzle[position+D[direction]].

Your position of course is now a single variable instead of a pair of coordinates. The padding around the border tells you if you've reached the edge of the board and should be a character that is never used in the interior of the puzzle.