Given a positive integer N, the task is to print the Upper Hessenberg matrix of order N which includes any one-digit random positive integer as its non-zero elements.
Upper Hessenberg matrix is a square matrix in which all of its elements below the sub-diagonal are zero. In mathematical term mat[i][j] = 0 for all i > j + 1.
Input: N = 3
1 2 8
1 3 4
0 3 4
Input: N = 4
1 2 2 3
1 3 4 2
0 3 4 2
0 0 1 4
Approach: For printing an upper Hessenberg matrix with one-digit positive elements print zero for all the cells of the matrix where i > j + 1 and any single-digit random number with help of rand() function.
Below is the implementation of the above approach:
3 6 7 5 3 5 6 2 0 9 1 2 0 0 7 0
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Print Lower Hessenberg matrix of order N
- Minimum number of steps to convert a given matrix into Upper Hessenberg matrix
- Minimum steps required to convert the matrix into lower hessenberg matrix
- Program to print Lower triangular and Upper triangular matrix of an array
- Maximize sum of N X N upper left sub-matrix from given 2N X 2N matrix
- Print all elements in sorted order from row and column wise sorted matrix
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Program to check if matrix is upper triangular
- Sorting rows of matrix in ascending order followed by columns in descending order
- Sorting rows of matrix in descending order followed by columns in ascending order
- Find trace of matrix formed by adding Row-major and Column-major order of same matrix
- Program to swap upper diagonal elements with lower diagonal elements of matrix.
- Sort a Matrix in all way increasing order
- Sum of both diagonals of a spiral odd-order square matrix
- In-place convert matrix in specific order
- Arrange numbers 1 to N^2 in a Zig-Zag Matrix in ascending order
- Check if row-major order path of Matrix is palindrome or not
- Search in a sorted 2D matrix (Stored in row major order)
- Print prime numbers from 1 to N in reverse order
- Program to print numbers from N to 1 in reverse order
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.