Ask Question
30 April, 06:18

Objective:This assignment is designed to give you experience with thinking about algorithm analysis and performanceevaluation. Project DescriptionYou will analyze three algorithms to solve the maximum contiguous subsequence sum problem, and then evaluate the performance of instructor-supplied implementations of those three algorithms. You will compare your theoretical results to your actual results in a written report. What is the maximum contiguous subsequence sum problem? Given a sequence of integers A1, A2 ... An (where the integers may be positive or negative), find a subsequence Aj, ..., Ak that has the maximum value of all possible subsequences. The maximum contiguous subsequence sum is defined to be zero if all of the integers in the sequence are negative.

+1
Answers (1)
  1. 30 April, 08:32
    0
    Check the explanation

    Explanation:

    #include

    /*Function to return max sum such that no two elements

    are adjacent * /

    int FindMaxSum (int arr[], int n)

    {

    int incl = arr[0];

    int excl = 0;

    int excl_new;

    int i;

    for (i = 1; i < n; i++)

    {

    / * current max excluding i * /

    excl_new = (incl > excl) ? incl: excl;

    / * current max including i * /

    incl = excl + arr[i];

    excl = excl_new;

    }

    / * return max of incl and excl * /

    return ((incl > excl) ? incl : excl);

    }

    / * Driver program to test above function * /

    int main ()

    {

    int arr[] = {5, 5, 10, 100, 10, 5};

    printf ("%d / n", FindMaxSum (arr, 6));

    getchar ();

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Objective:This assignment is designed to give you experience with thinking about algorithm analysis and performanceevaluation. Project ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers