Question: In C language Q3) Write a C function using recursion to check if a given array of integer values of size n is a partially
In C language

Q3) Write a C function using recursion to check if a given array of integer values of size n is a partially sorted array of degree m or not. The function IsPartiallySoreted will return 1 if the given array is an imperfect sorted array of degree less than or equal m and return 0 if the imperfect degree is greater than m. [40 points] Given an array of n elements, where each element is at most m positions away from its target position if the array was sorted correctly, we call this array an imperfect sorted array of degree m NOTE: you may assume that all the values in the array are unique (no duplicates). Examples, Is the following array is an imperfect sorted array of degree 2 ? in other words, m = 2 1 0 1 2 3 4 5 6 7 8 3 | 7 8 10 9 12 14 11 17 20 YES: We can see that for a sorted array the values 9, 10, 12, 14, and 11 are not in their correct positions, however, to put any of them in its correct position we only need to move it at most 2 positions, for example, 11 will move from Array[7] to Array[5] and 10 will move from Array[3] to Array[4] Examples, The following array Is NOT an imperfect sorted array of degree 3, in other words, m = 3 0 10 1 11 2 51 3 21 4 9 5 7 6 5 7 1 8 12 | | | 15 NO: We can see that for value 1 to be in the correct position it has to move from Array[7] to Array[0], therefore m > 3 Q3) Write a C function using recursion to check if a given array of integer values of size n is a partially sorted array of degree m or not. The function IsPartiallySoreted will return 1 if the given array is an imperfect sorted array of degree less than or equal m and return 0 if the imperfect degree is greater than m. [40 points] Given an array of n elements, where each element is at most m positions away from its target position if the array was sorted correctly, we call this array an imperfect sorted array of degree m NOTE: you may assume that all the values in the array are unique (no duplicates). Examples, Is the following array is an imperfect sorted array of degree 2 ? in other words, m = 2 1 0 1 2 3 4 5 6 7 8 3 | 7 8 10 9 12 14 11 17 20 YES: We can see that for a sorted array the values 9, 10, 12, 14, and 11 are not in their correct positions, however, to put any of them in its correct position we only need to move it at most 2 positions, for example, 11 will move from Array[7] to Array[5] and 10 will move from Array[3] to Array[4] Examples, The following array Is NOT an imperfect sorted array of degree 3, in other words, m = 3 0 10 1 11 2 51 3 21 4 9 5 7 6 5 7 1 8 12 | | | 15 NO: We can see that for value 1 to be in the correct position it has to move from Array[7] to Array[0], therefore m > 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
