Segmentation Fault

This is a discussion on Segmentation Fault within the C Programming forums, part of the General Programming Boards category; How about starting from the end of the node list and working backwards (instead of forwards like you current program). ...

  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,im 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.

Page 4 of 4 FirstFirst 1234
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, 02: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, 02:29 PM
  4. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 12:33 PM
  5. Segmentation fault...
    By alvifarooq in forum C++ Programming
    Replies: 14
    Last Post: 09-26-2004, 12:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21