Memory Referrence Issue In Recursive Algorithm
Hello, I have a problem with the algorithm in the picture. What it does is take the values from a single dimensional array and puts them into an N dimensional array (additional explanation in the picture).
This algorithm is recursive, and my problem I have is with the 'indexerArr' array of integers, where when the function calls itself again, then returns to itself, the function will remember the changes that were done to the indexer array in the self call.
For example, let's say that the function receives the following parameters:
arr = { 1, 2, 3, 7, 8, 9 }
arrToAssemble = { {3, 2, 1}, {9, 8, 7} }
indexerArr = { 0, 0 }
currRank = 0
The function will enter the first for loop, call itself, and in that call the second for loop will be executed. And the 'arrToAssemmble' array returned will be { {1, 2, 3}, {9, 8, 7} } and the indexer array which is NOT returned will be { 0, 3 }, then it will become { 1, 3 }, and upon calling itself again, it will arrive at the second for loop which will not run because of the index being out of range.
It's like the function returning to itself a parameter which is not supposed to return.
Any suggestions to solve this?
This algorithm is recursive, and my problem I have is with the 'indexerArr' array of integers, where when the function calls itself again, then returns to itself, the function will remember the changes that were done to the indexer array in the self call.
For example, let's say that the function receives the following parameters:
arr = { 1, 2, 3, 7, 8, 9 }
arrToAssemble = { {3, 2, 1}, {9, 8, 7} }
indexerArr = { 0, 0 }
currRank = 0
The function will enter the first for loop, call itself, and in that call the second for loop will be executed. And the 'arrToAssemmble' array returned will be { {1, 2, 3}, {9, 8, 7} } and the indexer array which is NOT returned will be { 0, 3 }, then it will become { 1, 3 }, and upon calling itself again, it will arrive at the second for loop which will not run because of the index being out of range.
It's like the function returning to itself a parameter which is not supposed to return.
Any suggestions to solve this?
