# Write a program to rearrange the 16 squares to get original big square ??

262 views

A square picture is cut into 16 squares and then shuffled. Write a program to rearrange the 16 squares to get original big square ??

posted Oct 29, 2013
Looking for an answer?  Promote on:

These 16 squares are of same size or different size??
Similar Questions

Result should be stored in new linked list.

Given a 2d array, u need to sort the 2 diagonals independently.
And the elements in diagonal should remain in diagonal only.

INPUT =>
24 2 3 4 7

6 13 8 5 10

11 12 9 14 15

16 21 18 25 20

17 22 23 24 1

OUTPUT =>
1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

suppose

A(n,m) =
1 2 3
4 5 6
7 8 9

and

B(p, q) =
1 1
1 1

What is best method to find min of square of difference of sub-matrices of A and B e.g.

sub-matrices of A =

1 2    |     2 3   |    4 5    |   5 6
3 4    |     5 6   |    7 8    |   8 9

Difference of first sub-matrix of A with B =

(1-1)  (2-1)    = |     0 1
(3-1)  (4-1)      |     2 3

sum of square of elements = 0*0 + 1*1 + 2*2 + 3*3 = 14

similar steps for other sub-matrices of A

Please suggest looking for an alternate method or algorithm which has time complexity less than O(n*m*p*q)