Question: this function sodo code Convert it to c++ code Memoized Solution COLLECT_APPLES (apples []) create array result[N][M] initialize result[] [] to 1 resutt[0][0]=apples[0][0] MAX_APPLES (N-1,
Memoized Solution COLLECT_APPLES (apples []) create array result[N][M] initialize result[] [] to 1 resutt[0][0]=apples[0][0] MAX_APPLES (N-1, M-1, apples, result) return result [N1][M1] MAX_APPLES (i,j, apples [], result []) if (result [i][j]!=1): return result [i][j] max_left =0, max_up =0 if (j>0): max_left = MAX_APPLES (i,j1) if (i>0): max_up = MAX_APPLES (i1,j) result [i][j]=apples[i][j]+ MAX(max_left, max_up) return result [i][j]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
