Hello,
I need help in writing a function which declared as following:
void ReconstructPermutation(pointer* start, int perm[], int* permSize);
start: contain the address of the cell (which mean that it is a pointer to a pointer, this is why its type is pointer*).
the function update the array perm to contain the Permutation as numbers in the right order, and update the permutation length by permSize.
We can assume that perm is large enough to contain the permutation.
permutation example:
http://www.fastup.co.il/images/65369635.jpg
running example:
int perm[4], permSize, i;
pointer seq[4] = {NULL}; /* seq is of type array of pointers. */
/* Define the permutation with pointers: */
pointer* start = seq + 2; /* start is of type pointer to pointer. */
seq[2] = seq + 0; seq[0] = seq + 3; seq[3] = seq + 1;
ReconstructPermutation(start, perm, &permSize);
printf(">>> PERMUTATION IS: \n");
for (i = 0 ; i < permSize ; ++i)
printf("%d ", perm[i]);
printf("\n");
Output:
>>> PERMUTATION IS: 2 0 3 1
Thank you,
Dan