Thread: Segmentation Fault

  1. #46
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    How about starting from the end of the node list and working backwards (instead of forwards like you current program). Do it in steps, and record the values to the end as you go through, so you don't traverse the same path twice. For example, in this:
    7 8 9 10
    7 9 10
    7 10
    ... you've worked out the max value for getting from 7 to 10, so store that away somewhere. Then, if you want to get from 6 to 10, you actually only need to get from 6 to 7, then add the value of that one hop to the max value already stored in 7. You never need to go through all the combinations of 6 to 10.

    Of course, in a prog, you'd start by checking 9 to 10, then move backwards.

    Am I making sense here, or just rambling?!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  2. #47
    Registered User Lost__Soul's Avatar
    Join Date
    Mar 2003
    Posts
    82
    Weel,since i have to move forward at least once,i´m going to do like this:find the first path,then move backwards,but when i move backwards,some variable similar to maxpeso already knows the sum from all the nodes in the path.This way,i only have to sum the new nodes.I realized that the program takes a lot of time in somador looking for the number to sum.Dont know if this is going to solve the eficience problem,but it sure is going to help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation fault problem
    By odedbobi in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2008, 03:36 AM
  2. Segmentation fault
    By bennyandthejets in forum C++ Programming
    Replies: 7
    Last Post: 09-07-2005, 05:04 PM
  3. Segmentation fault
    By NoUse in forum C Programming
    Replies: 4
    Last Post: 03-26-2005, 03:29 PM
  4. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  5. Segmentation fault...
    By alvifarooq in forum C++ Programming
    Replies: 14
    Last Post: 09-26-2004, 12:53 PM