Question: C++ rotate array to the right by 1 // REQUIRES: there are at least n elements in arr; // n >= 1 // MODIFIES: the
C++ rotate array to the right by 1
// REQUIRES: there are at least n elements in arr; // n >= 1 // MODIFIES: the elements in arr // EFFECTS: All elements are "shifted" right by one unit, with the // last element wrapping around to the beginning. // EXAMPLE: If arr contains [0,1,3,3,4], it would be modified to // contain [4,0,1,3,3] // NOTE: You must use traversal by pointer. // You may not use an extra array. void slideRight(int arr[], int n) {
}
I am really confused about how to do this using pointers? Can anyone give me some suggestions?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
