need help for a search loop
-
currently i am developing a program which uses a deep search loop, story is similar to search a coin along all points of roads in a city. the function works fine for a small city, but once the city is big and contains more roads, the function crashed. the function looks like: //-------------- void FindSomething(...) { //first line /*code ...... Code*/ //crash line just before call next search FindSomething(...); } //------------------- when the function crashes, I detect crash point, which is just before calling next loop but not enter the function (not crashed at //first line). i am wondering why it crashes at there? that line is empty before I add debug code. I suspect that a search loop can not go to too deep otherwise system can not controls it over (or heap issue?). I detected the loop goes to around 20,000 times at crash time, it is not too far. could you explain why and any help?
-
currently i am developing a program which uses a deep search loop, story is similar to search a coin along all points of roads in a city. the function works fine for a small city, but once the city is big and contains more roads, the function crashed. the function looks like: //-------------- void FindSomething(...) { //first line /*code ...... Code*/ //crash line just before call next search FindSomething(...); } //------------------- when the function crashes, I detect crash point, which is just before calling next loop but not enter the function (not crashed at //first line). i am wondering why it crashes at there? that line is empty before I add debug code. I suspect that a search loop can not go to too deep otherwise system can not controls it over (or heap issue?). I detected the loop goes to around 20,000 times at crash time, it is not too far. could you explain why and any help?
-
may be that your recursive search is too deep ... Did you try to increase the stack size in the project > settings > link options
(1) which one is exactly for this? .../Customer/Link incrementally? (2)what is strategy used by Windows-Paint to fill picture? when I draw complex roads to simulate my situation, Windows-Piant fills all roads properly. If i can "fill" as Windows-Paint does, my search will be fine. any suggestion?
-
currently i am developing a program which uses a deep search loop, story is similar to search a coin along all points of roads in a city. the function works fine for a small city, but once the city is big and contains more roads, the function crashed. the function looks like: //-------------- void FindSomething(...) { //first line /*code ...... Code*/ //crash line just before call next search FindSomething(...); } //------------------- when the function crashes, I detect crash point, which is just before calling next loop but not enter the function (not crashed at //first line). i am wondering why it crashes at there? that line is empty before I add debug code. I suspect that a search loop can not go to too deep otherwise system can not controls it over (or heap issue?). I detected the loop goes to around 20,000 times at crash time, it is not too far. could you explain why and any help?
that reminds me of the traveling salesman problem ( or a variant ), which is a NP Hard problem. so it will work for a small "city" size, but as you incread the city size lineary, the computation will increase expotienatly (sp?) http://mathworld.wolfram.com/TravelingSalesmanProblem.html[^]
Maximilien Lincourt Your Head A Splode - Strong Bad