Showing posts with label Algorithms. Show all posts
Showing posts with label Algorithms. Show all posts

Sunday, May 5, 2013

Thursday, April 25, 2013

Tuesday, April 23, 2013

Prime Factorization

Ref: Programming Challenges

Thursday, April 11, 2013

Kadane's Algorithm - Maximum Sub Array Sum


float kadane()
{   int i;
    int maxsofar = 0, current_max = 0;
    for (i = 0; i < n; i++) {
        current_max += x[i];
        if (current_max < 0)
            current_max = 0;
        if (maxsofar < current_max)
            maxsofar = current_max;
    }
    return maxsofar;
}