a test program to test the two algorithms

bidirectional approach is 5 times more efficient.