Give an algorithm that prints the first 10 elements of each

Give an algorithm that prints the first 10 elements of each row in a two-dimensional n times n array. If n

Solution

The running time of the above algorithm is O(n). Because see at step 2 and 6 the loop is running for n time. in this loop we are selecting the row to print, because we need to print for every row 10 values from column. and in loop 3 and 7 if you observe this loop is running only 10 times which means constant running time. So total running time of the algorithm will be 10n which is of O(n).

 Give an algorithm that prints the first 10 elements of each row in a two-dimensional n times n array. If n SolutionThe running time of the above algorithm is O

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site