C++ Programming Assignment. Define a boolean valued function named is_sorted that takes two parameters, an integer array named a and an integer named n that
C++ Programming Assignment.
Define a boolean valued function named is_sorted that takes two parameters, an integer array named a and an integer named n that indicates how much of the array is filled with data. The function examines the first n values in array a and returns true if the values are in sorted order, smallest to largest, and returns false otherwise. Algorithm: use a for loop to go through the array checking for any out of order pairs, ie if a[i] > a[i + 1] for any value of i from 0 to n - 2 then the array is not sorted and the function returns false. If the for loop completes without returning false, then return true. Write a main program that defines and initializes several different arrays, some sorted and some not, and use them to est the function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started