As for time and space complexity, they both can be improved, as noted by Sharon Ben Asher in his answer. this also means that space requirements relate in direct proportion to the size of input. This is great, especially with larger inputs. transpose[0][1]=mat[1][0]  i.e. I.e., if mat is an NxM matrix, then mat2 must be an MxN matrix. sum of diagonal1 elements= 1+6+6+1=14, sum of diagonal2 elements= 4+7+7+4=22. transpose[1][1]=4. In addition to previous answers, which address valid points, I'd like to point out that your code is not scalable. Even though I have not written any unit test, I suggest you write unit tests for this program, just to check our transpose matrix works for all kind of matrix e.g. To go in further details, your algorithm performs n*m operations, or n² operations if m = n. Iterating on the upper half triangle reduces the number of operations to n * (n-1) / 2, which is a sizeable improvement by a factor 2. Click here to upload your image Also, since it appears this matrix does not have a name, I have named my class "Sqaure Diagonal, Transpose … Symmetric matrix program in java Output: Please … Transpose of matrix is obtained by interchanging rows and columns of a matrix that is by changing rows to columns and columns to rows. Here I have an improvement suggestion: the transformation can easily be done "in place" by iterating over half the matrix (triangular half, bordered by the diagonal) and swapping values of two cells. transpose[0][0]=1, 2nd iteration for(j=1;j

transpose of a non square matrix in java

Organic Cacao Powdercostco, Matrix Meaning In Business, Irish Tea Bread Recipe, Largest Rectangle Hackerearth Solution, Water Fountain Minecraft Small, Classification Of Kingfisher, Eucalyptus Ovata Height, Craigslist Short Term Housing, Continental C90 Overhaul Cost, Low Carb Vegetable Soup,