Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

MCSP

Name: Anonymous 2010-08-28 17:19

How do you get an O(n) running time of a Maximum Consecutive Sub-sequence Product. I have a O(n^2) algorithm now, but I need a O(n) runtime.

ar is the array

k=ar.length;
          

            pro=BigInteger.ONE;
            max=BigInteger.valueOf(ar[0]);
            for(i=0;i<k;i++)
            {
                pro=BigInteger.valueOf(ar[i]);
                if(pro.compareTo(max)>0) {
                    max=pro;
                }
                for(j=i+1;j<k;j++)
                {
                    pro=pro.multiply(BigInteger.valueOf(ar[j]));
                    if(pro.compareTo(max)>0) 
                        max=pro;
                }

Name: Anonymous 2010-09-08 15:58

Jewish liberation ?

Name: Anonymous 2010-09-08 19:27

>>39
You might just be seeing the breakdown of your ``multiplication and division are O(1) time'' assumption. The divisions can be replaced by keeping both negative and positive running totals.

Name: Anonymous 2010-09-08 21:29

>>42
The divisions can be replaced by keeping both negative and positive running totals.

what do you mean by this?

Name: Anonymous 2010-09-09 3:46

>>43
Maybe he means that you should learn to program.

Name: Anonymous 2010-12-17 1:31

Xarn is a bad boyfriend

Name: Anonymous 2010-12-17 1:39

This post brought to you by the Gay Nigger Association of America

Name: Anonymous 2013-01-19 23:38

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List