问题
Can you please give me some sort of pseudo code for matrix transposition using recursion? If it is in one function that will be great.
PS: This might not be a question but I couldn't find the information anywhere. If you know of a site about pseudo codes for recursion that will be awesome.
回答1:
For a square MxM matrix:
function transpose (x0, y0, x1, y1)
if (M > 1)
transpose (0, 0, M/2, M/2) // A
transpose (0, M/2, M/2, M) // B
transpose (M/2, 0, M, M/2) // C
transpose (M/2, M/2, M, M) // D
swap blocks B and C
endif
transpose (0, 0, M, M)
来源:https://stackoverflow.com/questions/13291231/matrix-transposition-using-recusrion