CSCI 2300 Lab 8 Spring 2015, 4/8/15

This lab is about Dynamic Programming - Please read Chapter 6 of DG's book.
  1. 6.1 (DG) - Design an algorithm to solve this problem. Implement that algorithm, (Hint: You may want to have variables runningsum and bestmax. If runningsum > bestmax then replace bestmax by running sum. if running sum is < 0 then you may want to reset runningsum to zero. Increase the index of the array). Also output the contiguous subsequence) use the data from the book for testing.
  2. Write a program to compute the length of longest nondecreasing subsequence in a given array of integers. The following is the way we formulated to compute the length at position j. use the data
    If Array indices start from 0.
    Initialization: len[0]=1;len[j]=1 for all j
    Computation: to calculate len[j]
    for (i=0;i<j;i++)
     if (a[i] ≤ a[j])
      if (len[j] < len[i]+1)
        len[j]=len[i]+1
    
  3. Do problem 6.2 (DG) Your job is to write the formulation for Dynamic Porgramming in terms of the following equations - given a[i], write the equation for finding min_penalty if one places a hotel in ith location and write a program to solve it. Data consists of number of locations, then the list of mile posts You may use the data for your program.