Given a matrix of order NxN, Find the minimum number of steps to convert given matrix into Upper Hessenberg matrix. In each step, the only operation allowed is to decrease or increase any element value by 1.
Input : N=3
1 2 8
1 3 4
2 3 4
Decrease the element a 2 times.
Now the matrix is upper hessenberg
Input : N=4
1 2 2 3
1 3 4 2
3 3 4 2
-1 0 1 4
- For a matrix to be Upper Hessenberg matrix all of its elements below sub-diagonal must be equal zero, i.e Aij = 0 for all i > j+1..
- The minimum number of steps required to convert a given matrix in the upper Hessenberg matrix is equal to the sum of the absolute values of all Aij for all i > j + 1.
- The modulus value of the element is taken into account because both the increase and decrease of the element count as a single step.
Below is the implementation of the above approach:
Time complexity : O(N*N)
- Minimum steps required to convert the matrix into lower hessenberg matrix
- Minimum number of steps to convert a given matrix into Diagonally Dominant Matrix
- Print Upper Hessenberg matrix of order N
- Minimum steps required to convert X to Y where a binary matrix represents the possible conversions
- Maximize sum of N X N upper left sub-matrix from given 2N X 2N matrix
- Minimum steps to get 1 at the center of a binary matrix
- Minimum steps required to reach the end of a matrix | Set 2
- Find minimum steps required to reach the end of a matrix | Set - 1
- Find minimum steps required to reach the end of a matrix | Set 2
- Minimum steps to reach any of the boundary edges of a matrix | Set 1
- Minimum steps to reach any of the boundary edges of a matrix | Set-2
- Print Lower Hessenberg matrix of order N
- Minimum cost to convert 3 X 3 matrix into magic square
- C++ program to Convert a Matrix to Sparse Matrix
- Convert given Matrix into sorted Spiral Matrix
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.