![]() |
VOOZH | about |
Here, we will see how to sort the 2D Array across rows using a C program:
Input:
8 5 7 2 7 3 0 1 8 5 3 2 9 4 2 1
Output:
2 5 7 8 0 1 3 7 2 3 5 8 1 2 4 9
In this approach, we use Bubble Sort. First Start iterating through each row of the given 2D array, and sort elements of each row using the Bubble sort sorting algorithm.
Below is the implementation of the above approach:
Input Array 8 5 7 2 7 3 0 1 8 5 3 2 9 4 2 1 Row-Wise Sorted 2D Array 2 5 7 8 0 1 3 7 2 3 5 8 1 2 4 9
Time Complexity: O(r*c*max(r,c)).
Auxiliary Space: O(1).