Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need help for a search loop

need help for a search loop

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    includeh10
    wrote on last edited by
    #1

    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?

    X M 2 Replies Last reply
    0
    • I includeh10

      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?

      X Offline
      X Offline
      XtremDev
      wrote on last edited by
      #2

      may be that your recursive search is too deep ... Did you try to increase the stack size in the project > settings > link options

      I 1 Reply Last reply
      0
      • X XtremDev

        may be that your recursive search is too deep ... Did you try to increase the stack size in the project > settings > link options

        I Offline
        I Offline
        includeh10
        wrote on last edited by
        #3

        (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?

        1 Reply Last reply
        0
        • I includeh10

          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?

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups