NO LOOPS USING RECURSION * @param data * @param idx1 * @param idx2 * @return the array after the it

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

NO LOOPS USING RECURSION * @param data * @param idx1 * @param idx2 * @return the array after the it

Post by answerhappygod »

NO LOOPS USING RECURSION
* @param data
* @param idx1
* @param idx2
* @return the array after the items at idx1 and
idx2 are swapped. If either
* indices are
invalid, return null.
*/
public static int[] swap(int[] data, int idx1,
int idx2) {
return null; //to be
completed
}
/**
*
* @param data
* @return the first index of where data isn't
sorted in ascending order. If
* data is sorted,
return the length of the array. For example {10, 20,
* 90, 5, 70} would
return 3 (90 > 5). If data is invalid, return -1;
*/
public static int partSorted(int[] data) {
return -1; //to be
completed
}
/**
*
* @param data
* @return true if the sorted array contains any
duplicates, false otherwise.
*/
public static boolean duplicates(int[] data)
{
return false; //to be
completed
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply