Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program that passes the given test cases while following OOP concepts only. Test Case: TEST(rotateArray, rotate1) { int arr[] = {1,2,3,4,5,6}; int
Write a C++ program that passes the given test cases while following OOP concepts only.
Test Case:
TEST(rotateArray, rotate1) {
int arr[] = {1,2,3,4,5,6};
int a[] = {2,3,1,5,6,4};
int *arr1 = rotateArray(arr, 6, 2, 2);
for (int i = 0; i
ASSERT_EQ(a[i], arr1[i]);
}
}
TEST(rotateArray, rotate2) {
int arr2[] = {1,4,3,11,7,9,5,10,12,6,2,8};
int a1[] = {4,3,11,1,9,5,10,7,6,2,8,12};
int *arr3 = rotateArray(arr2, 12, 3, 3);
for (int i = 0; i
ASSERT_EQ(a1[i], arr3[i]);
}
}
Write a function named as rotateArray that takes an array of type integer, its size, input n whichshifts elements of an array to the right n times, and a number m which divide array into m partsas function parameters. You first need to need to divide array into m number of parts and then shifts elements of an array to the right n times. Array under consideration is circular. Function Prototype: rotateArray (int *arr, int sizeofArray, int n, int m ) Original Array Updated Array ( n=2 and m=2 )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started