posting this second time.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I'm posting this second time. 

 

Write a function named outOfOrder. This function should receive as parameters (in this order), an array of doubles and the used size of the array. The function should
return an integer. The function should test the array to see if its elements are out of order, meaning that it checks to see if the array violates the following condition:
a [0] <= a (1] <= a[2] <= ...
The function should return -1 if the elements are NOT out of order; otherwise it should return the index of the first element of the array that is out of order. For example,
consider the following array:
double a[51 = {1.2, 2.1, 3.3, 2.5, 4.5);
In this array, a[3] is the first element that is out of order and so the function should return 3. If the array were sorted, the function would return -1.
Grading:
The tests for this problem will create an array of random doubles. They will then call your function, passing the array and size as parameters to your function. Once your
function ends, the array will be checked to see that your function returns the correct value.
v Grading 5
Save
Run Tests
code.cpp 0
O New
O Full Screen ¢
In Order
NOT RUN
Not run
Out of Order (test 1)
Not run
NOT RUN
a Out of Order (test 2)
NOT RUN
Not run
Out of Order (test 3)
NOT RUN
Not run
Test Function Declaration
Not run
Transcribed Image Text:Write a function named outOfOrder. This function should receive as parameters (in this order), an array of doubles and the used size of the array. The function should return an integer. The function should test the array to see if its elements are out of order, meaning that it checks to see if the array violates the following condition: a [0] <= a (1] <= a[2] <= ... The function should return -1 if the elements are NOT out of order; otherwise it should return the index of the first element of the array that is out of order. For example, consider the following array: double a[51 = {1.2, 2.1, 3.3, 2.5, 4.5); In this array, a[3] is the first element that is out of order and so the function should return 3. If the array were sorted, the function would return -1. Grading: The tests for this problem will create an array of random doubles. They will then call your function, passing the array and size as parameters to your function. Once your function ends, the array will be checked to see that your function returns the correct value. v Grading 5 Save Run Tests code.cpp 0 O New O Full Screen ¢ In Order NOT RUN Not run Out of Order (test 1) Not run NOT RUN a Out of Order (test 2) NOT RUN Not run Out of Order (test 3) NOT RUN Not run Test Function Declaration Not run
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY