Please see the figure in the inset for an illustration. Let us suppose each task can have “2†different (latency,power) operating modes. Also the latency values of these modes are the same while power values are different (across tasks). Hence two tasks s1 and s2 will have different power values but same latency values for their operating modes. You are given a cumulative latency constraint T. Give an algorithm which allocates an operating mode to each task subject to latency constraints while minimizing the total power. Does your algorithm run in polynomial time (while guaranteeing correct results)? (if it helps, you can assume the latency, power and T are all integers). { Use 0 1 Knapsack} C++ code is required dynamic prograaming matrix required Q2) ) Let us suppose n=2. Let us suppose that the power vs latency relationship is linear and latency can take any positive value as long as it is less than some MAX constraint (not subject to an integer number of distinct states). Describe a formal approach to finding the best operating mode for the two tasks subject to T (latency constraints) while minimizing the total power. In this context an operating mode is an allocation of latency for each task. Solution #include<iostream.h> #include<conio.h> class S { private: int por; int lat; int* s; public: S(); S(int M, int N); ~S(); }; S::S() { int * s = NULL; } S::S(int N) { int * s = new int[N * N]; this->por = N; this->cols = N; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(i==j) s[i * N + j] = 1; else s[i * N + j] = 0; } } } S::S(int M, int N){ int * s = new double[M * N]; this->por = M; this->lat = N; for(int i = 0; i < M; i++){ for(int j = 0; j < N; j++) matrix[i * N + j] = 0; } } S::~S(){ delete [] s; } void main() { S s1,s2; int n; s1=new S(n); s2=new S(n); getch(); } .