Spread the post

Check if array is in ascending order

Given an array of integers values. Write an efficient program (algorithm) to find given array is ascending order (sorted form).

Example

Suppose array contain following nodes. view input and accepted output.

Stack Areamainarray1array1 is not sorted [0] 9 [1] 2 [2] 4 [3] 3 [4] 7array2array2 is sorted [0] 1 [1] 2 [2] 3 [3] 4 [4] 5size (int) =5

Explanation

Program for check given array in ascending order. Time complexity O(n).

Output

View process.

Stack Areamainarray1 [0] 9 [1] 2 [2] 4 [3] 3 [4] 7array2 [0] 1 [1] 2 [2] 3 [3] 4 [4] 5size (int) =5check_sortedarray(pointer)index (int) =1size (int) =5status (int) =1

View steps of execution

Submit your solution in comment section.

Spread the post

Recommended Posts: