Create a C program that tests whether two sequences of positive numbers are order equivalent.

Two sequences a and b are order equivalent if they have the same number of elements and they both contain less than two numbers or if for all i, j, 1 <= i, j <= n, where n is the length of a sequence a[i] <= a[j] if and only if b[i] <= b[j].

Examples of order equivalent sequences:

7 5 9 13 12 and 4 2 25 33 26
12 and 8

The program must accept the two sequences with no separator between the two. If the number of numbers accepted is n, the first n/2 numbers are assumed to be in the first sequence and the rest form the second sequence. The program must then check that for order equivalence and must print the result. You can assume that the maximum size of the two sequences is 100. You can also use 0 or any negative number to mark the end of the sequence.

Please remember to organize the code as below:

  • Have two functions besides main:
    • one that accepts the two sequences and
    • the other that checks for order equivalence and returns an integer depending on the test
  • The main function prints the message for the user.
  • You cannot use any global variables.
  • Look at the sample program int_array.c (posted at the D2L site) to see how to perform read/write operations on arrays.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.