Question: Write a method named reverseFirstK that accepts an array of integers and an index k as parameters and modifies the first k elements of the

 Write a method named reverseFirstK that accepts an array of integers

Write a method named reverseFirstK that accepts an array of integers and an index k as parameters and modifies the first k elements of the array to be in reverse order. For example, if the array a stores {10,2,33,55,9,17,6}, the call of reverseFirstK (a,5) should reverse the first 5 elements, modifying it to store {9,55,33,2,10,17,6}. If the value of k is 1,0 , negative, or greater than the length of the array, do not modify the array

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!