5 Replies Latest reply: Nov 18, 2007 3:54 PM by 807600 RSS

    Could someone help me with arrays & recursion??

    807600
      Hi, I'm new here and I'm having trouble.

      I have to write a java application which uses recursion to find the maximal contiguous sum in a list of integers.

      The input is read from a text file where each line represents a list containing the following integers:

      For example, it might contain

      7 -2 -4 30 15 -7 -5 1000
      2 -50 100
      6 1000 -2000 900 2800 -2900 2801
      4 100 -10 5 8
      4 100 -50 5 8

      And for the output, for each line of data read, I have to display the largest sum of consecutive integers in the list followed by the list itself. For example for the lists above, my output would be:

      (on the left side is the largest sum of consecutive integers and on the right is the list of integers)

      1033
        • 1. Re: Could someone help me with arrays & recursion??
          807600
          Please don't double post. Since this is the smaller post, let's consider this one dead.

          For anyone else who will help, please go to thread:

          http://forum.java.sun.com/thread.jspa?threadID=5237811&tstart=0
          • 2. Re: Could someone help me with arrays & recursion??
            807600
            I'm sorry about that. I didn't mean to double post. I accidently clicked "post" before I finished typing.
            • 3. Re: Could someone help me with arrays & recursion??
              800282
              R.S. wrote:
              Hi, I'm new here and I'm having trouble.

              I have to write a java application which uses recursion to find the maximal contiguous sum in a list of integers.

              The input is read from a text file where each line represents a list containing the following integers:

              For example, it might contain

              7 -2 -4 30 15 -7 -5 1000
              2 -50 100
              6 1000 -2000 900 2800 -2900 2801
              4 100 -10 5 8
              4 100 -50 5 8

              And for the output, for each line of data read, I have to display the largest sum of consecutive integers in the list followed by the list itself. For example for the lists above, my output would be:

              (on the left side is the largest sum of consecutive integers and on the right is the list of integers)

              1033
              Where did this 1033 come from? Could you explain your problem in a bit more detail and also post what you have done so far and explain where you are stuck: only posting the problem description sound a bit like "can some one do it for me", it's better to ask a specific question here.
              • 4. Re: Could someone help me with arrays & recursion??
                807600
                prometheuzz check the other thread.
                • 5. Re: Could someone help me with arrays & recursion??
                  807600
                  R.S. wrote:
                  I'm sorry about that. I didn't mean to double post. I accidently clicked "post" before I finished typing.
                  You can edit your posts, as long as nobody has responded to them yet.

                  Also, as a basic courtesy, if for some reason you needed to abandon a thread and start a new one, you should add a note to that effect in the first thread with a link to the other one.