MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / IsSorted

Function IsSorted

Arrays/13_IsSorted .cpp:18–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18int IsSorted(struct Array* arr)
19{
20 for (int i = 0; i < arr->length - 1; i++)
21 {
22 if (arr->A[i] > arr->A[i + 1]) // if 1st element is greater then 2nd element then it will k/as not sorted so return 0
23 return 0;
24 }
25
26 return 1; // if everything is ok and the element came successfully out of loop means it is sorted return 1 for thet
27}
28int main()
29{
30 struct Array arr;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected