Question: Given an input matrix A of size 2 x 2 where every element is an integer from 0 to 9, the TEN sequence is
Given an input matrix A of size 2" x 2" where every element is an integer from 0 to 9, the TEN sequence is defined as follows: If n = 0, the TEN sequence consists of only one integer that A contains; If n > 0, let s be the mode of elements of A (Note that the mode is the number that is repeated most often. If there are multiple modes, s would be the smallest one). You can divide matrix A into four submatrices of size 2-1 x 2-1, the upper left one, the upper right one, the lower left one and the lower right one. The TEN sequence of A is the concatenation of the following 5 sequences: {TEN sequence of the upper left submatrix}, {TEN sequence of the upper right submatrix}, You are given an integer n and a matrix of size 2" x 2". Please calculate the TEN sequence of this matrix. 1 12 52 2 {TEN sequence of the lower left submatrix}, {TEN sequence of the lower right submatrix}. Input The first line contains an integer n. (0 n 10) Next 2" lines each contains 2" integers, representing the matrix. Output The only line contains a sequence where each element ought to be an integer from 0 to 9. Adjacent numbers should be separated by a space. Example 1234 2345 1656 0987 Sample Input Sample Output 12252 37 1222 956587 00
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
