1) When writing out an algorithm please give a high level description/summary. 2
ID: 664133 • Letter: 1
Question
1) When writing out an algorithm please give a high level description/summary.
2) When giving a dynamic programming algorithm, make sure to give the recurrence equation for your algorithm along with a description of the underlying subproblems that needs to solved.
Explanation / Answer
string s; //Input String int k; //Input k char dp[21000][31][31]; //Set to -1 initially char solve(int startPointer, int leftRemoved, int rightRemoved) { int endPointer = s.ln - rightRemoved - (startPointer - leftRemoved) - 1; if(startPointer >= endPointer) return true; //Base Case char &ret = dp[startPointer][leftRemoved][rightRemoved]; if(ret != -1) return ret; ret = false; //Case where extremes are equal if(s[startPointer] == s[endPointer]) ret = solve(startPointer+1, leftRemoved, rightRemoved); //Check if you can remove one more element. //If yes, check after removing from front and back if(leftRemoved + rightRemovedRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.