Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

!!PLEASE SOLVE WITH C LANGUAGE!!! Part 3(35 points)
Implement the following function in skeleton code lab1part3.c:
You need to use circularShiftFromLeftToRight function and compareTwoArrays function
while implementing circularShiftUntilMinArr function.
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
Maximum element of the array: 9 HERE IS THE CODE STRUCTURE/SKELETON CODE lab1part3.c.: #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 left to right where last element of arr is
// shifted the first position of arr.
// Size of arr is n.
void circularShiftFromLeftToRight(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 left to right 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 findMax(const 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);
int maxElement = findMax(arr, n);
printf("Maximum element of the array: %d
", maxElement);
return 0;
}
void readInput(int arr[], int *nPtr)
{
// fill here
}
void printNumbers(const int arr[], int n)
{
// fill here
}
void circularShiftFromLeftToRight(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
}
int findMax(const int arr[], int n){
// fill here
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

Demand and Supply in Financial Markets

Answered: 1 week ago

Question

How did you feel about taking piano lessons as a child? (general)

Answered: 1 week ago