Fall06ProgAsnmt3

Fall06ProgAsnmt3 - (e.g., the DP-matrix). If the value is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Assignment 3 CSE 4081/5211 Fall 2006 Points: 20 Due: November 14 Graduate Class: Develop and implement an algorithm for detecting negative cycle in a weighted directed graph. Undergraduate Class: Implement the following three algorithms for 0-1 knapsack problem. (1) Dynamic programming algorithm. (2) Branch and bound algorithm, using greedy algorithm for rational knapsack problem as the bounding function to the former. (3) All the elements in the dynamic programming algorithm’s matrix are not needed for the final result. The recursive implementation of the recurrence equation (for DP algorithm) calculates only the needed elements but recalculates them multiple times that the DP algorithm avoids doing. Develop an algorithm combining the advantages of both the algorithms. The new algorithm is the same as the recursive algorithm, but before making a recursive call it checks if the value is already available in a data structure D
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (e.g., the DP-matrix). If the value is already available in D, then it does not make any recursive call, otherwise it does make the call. Once, the value is returned from the recursive call it is stored in D, so that the next time when it is needed no more recursive call is made. However, there is one catch to this algorithm. If D is the DP-matrix its initialization will have the same asymptotic complexity as that of the DP algorithm (still the run time will be faster than that of DP). This can be avoided by using some innovative data structure for D, e.g., a hash table. Write the algorithm before you implement it. The algorithm is related to memorization [http://en.wikipedia.org/wiki/Memoization, http://cs.wellesley.edu/~cs231/fall01/memoization.pdf]. You need to implement all these algorithms and experiment with them (over problem set with large input sizes)....
View Full Document

Ask a homework question - tutors are online