Tree Search ---- ------ Trax and Jax live in the tunnels inside the planet Pax. There are a lot of tunnels. But there is only one path through the tunnels from any point to any other point (no running around in circles possible). Trax needs to locate Jax, and fortunately she has a locator device that can help. The device, however, does not simply tell Trax where Jax is. Instead Trax can suggest to the device a possible location for Jax, and the device will tell her whether Jax is there and if not, which direction from the suggested location Jax is. Unfortunately the locator device uses a lot of power for each response, and can only answer a few queries. In this problem you write a program that talks to the locator device until you suggest the location where Jax is or run out of power. Your Input/Output ---- ------------ You write the program whose binary name is `treesearch'. The locator is implemented by a separate program whose name is `locator'. The `locator' program runs your `treesearch' program as a subprocess. The command that does this is locator [-trace] treesearch ... > '. In trace mode, any line output by your program that begins with a `*' will be traced but otherwise ignored. You can use such lines for debugging output, and you can use arguments passed to your program to tell your program to output these lines. The input tree, if not very large, may be printed or displayed in an X-window by the commands: print_tree sample.in display_tree sample.in You can replace `sample.in' by another locator input file. Jax's location is marked by a `*'. Test Case Descriptions And Output ---- ---- ------------ --- ------ In the test environment, the locator (and not your program) reads test case descriptions from its standard input and the locator (and not your program) writes test case output to its standard output. Each test case description has two lines. First a line containing just the test case name. Then a line containing N SEED where N is the number of tree nodes and SEED is an unsigned integer used to seed a pseudo-random number generator that generates the tunnel map. SEED is 9 digits long: 10**8 <= SEED < 10**9. The test case output written by the locator to its standard output (not your program) consists of first a line copying the test case name input line, then any trace output, and finally a single line containing either just `FOUND' or `POWER'. Sample Input ------ ----- -- SAMPLE 1 -- 11 785983564 -- SAMPLE 2 -- 35 352401876 Sample Output ------ ------ -- SAMPLE 1 -- FOUND -- SAMPLE 2 -- FOUND Sample Output in Trace Mode (with -trace) ------ ------ -- ----- ---- ----- ------- -- SAMPLE 1 -- >> (()((())())((()(())))) << 1 >> 7 << 8 >> FOUND FOUND -- SAMPLE 2 -- >> ((((((())...rest omitted, see sample.trace << 8 >> 5 << 26 >> 27 << 28 >> FOUND FOUND File: treesearch.txt Author: Bob Walton Date: Tue Oct 15 14:04:42 EDT 2019 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file.