How can I keep just 2 rows using modular arithmetic at the time of 2 D array, meaning I do not need to store the entire table, since I have a lot of items. This array will be used for knapsack problem.
cin>>sizeDesired >> number;
//create dynamic 2D array;
int **arr = newint*[sizeDesired];
for(int i = 0; i < sizeDesired; ++i)
arr[i] = newint[number];
//process some data
for (int k=0; k<sizeDesired; k++)
for (int n =0; n<number n++)
cin>> arr [k] [n];
//after 2 roows are full, I need to create 1 new row and delete the top row.
// how do I do that? Thanks!