| ||||||||||||||
| ||||||||||||||
|
||||||||||||||
|
Create a program that allows you to create a binary tree and then search it for a given data item. It should allow the user to choose whether to use a breadth-first or depth-first algorithm and will display the nodes that the algorithm had on the OPEN and CLOSED lists. If you do not know how to implement these algorithms, read the Generation5 essay.
GuidelinesHere is some pseudo-code (well, C++!) that might be used to set up a data tree:This code would set up the tree shown to the right (disregard the arrows).
Further ExplorationThis project is relatively trivial, since it doesn't do very much that is interesting. You might want to try and implement a hybrid algorithm: a depth-first algorithm that has a depth-threshold. In the first iteration it will only check perhaps 5 levels deep, and if the goal state is not found the depth is incremented and the search it tried again. This may sound inefficient, but in some cases it is a better option than either depth or breadth-first.
Solutions
Submitted: 24/05/2001 Article content copyright © James Matthews, 2001.
|
|
|||||||||||||
All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -