|
|
back to boardShow all messages Hide all messagesthe algorithm consist of transposition the most high soldier to the centre of the line and to the centre of the column. in cycle from 1 to n gives bubble sorting. Please can you explain how to do bubble sort in 2-d array here? I constructed such an algorithm. It requires the soldiers to be sorted by their height downwards. When the soldiers are sorted, take them one by one and fill the square diamond by diamond, starting from center. A "diamond" contains those cells (x,y) for which |x - x_center| + |y - y_center| == C, C ranges [0; n-1]. Edited by author 11.03.2009 08:54 There is a much simpler method, which also uses less memory. Hint: try a O(n) sort. Also try not to store n*n elements in memory (print line by line instead). |
|
|