Question: Part 3 ( 3 5 points ) ! ! PLEASE SOLVE IT IN C LANGUAGE!! Implement the following function in skeleton code lab 1 part

Part 3(35 points)!!PLEASE SOLVE IT IN C LANGUAGE!!
Implement the following function in skeleton code lab1part3.c:
// Circularly shift elements of arr from right to left until sequence of values in
// arr becomes the smallest considering all sequence of values obtained by circularly
// shifting elements in arr.
void circularShiftUntilMinArr(int arr[], int n);
You need to use circularShiftFromRightToLeft function and compareTwoArrays function
while implementing circularShiftUntilMinArr function.
Print out sum of the elements of two arrays one by one.
Assume that arr can have at most 500 elements in it. Hint: If you need to declare a local array in function
circularShiftUntilMinArr, you can set its size as 500.
Your task in this part to fill in the missing function definitions in skeleton code lab1part3.c.
main function will stay as it is. Sample Run:
Enter the number of elements:
6
Enter 6 elements:
485169
Array elements: 485169
After circularShiftUntilMinArr:
Array elements: 169485
Sum of original and shifted elements:
Element 0: 5
Element 1: 14
Element 2: 14
Element 3: 5
Element 4: 14
Element 5: 14 Here is the skeleton code lab1part3.c code structure: #include
#define SIZE 500
// reads numbers from the standard input into arr,
// and stores the number of read elements in the memory cell pointed to by nPtr
void readInput(int arr[], int *nPtr);
// prints the elements in arr[0..(n-1)]
void printNumbers(const int arr[], int n);
// Circularly shift elements of arr from right to left where last element of arr is
// shifted the first position of arr.
// Size of arr is n.
void circularShiftFromRightToLeft(int arr[], int n);
// Let n be the minimum of n1 and n2 where n1 and n2 are the number of elements in
// arr1 and arr2, respectively.
// Compare corresponding elements of arr1 and arr2 at each of the first n positions.
//
// If arr1 and arr2 has the same value in each position:
// Return 0 if n1== n2
// Return 1 if n1> n2
// Return -1 if n1< n2
//
// If arr1 has a larger value than arr2 considering the first position from the
// beginning at which arr1 and arr2 have a different value:
// Return 1
//
// If arr1 has a smaller value than arr2 considering the first position from the
// beginning at which arr1 and arr2 have a different value:
// Return -1
int compareTwoArrays(const int arr1[], const int arr2[], int n1, int n2);
// Circularly shift elements of arr from right to left until sequence of values in
// arr becomes the smallest considering all sequence of values obtained by circularly
// shifting elements in arr.
void circularShiftUntilMinArr(int arr[], int n);
int main()
{
int arr[SIZE];
int n;
readInput(arr, &n);
printNumbers(arr, n);
circularShiftUntilMinArr(arr, n);
printf("
After circularShiftUntilMinArr:
");
printNumbers(arr, n);
// Calculate the sum of the elements after shifting for two arrays
//----FILL HERE----//
return 0;
}
void readInput(int arr[], int *nPtr)
{
// fill here
}
void printNumbers(const int arr[], int n)
{
// fill here
}
void circularShiftFromRightToLeft(int arr[], int n)
{
// fill here
}
int compareTwoArrays(const int arr1[], const int arr2[], int n1, int n2)
{
// fill here
}
void circularShiftUntilMinArr(int arr[], int n)
{
// fill here
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!