Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

00 6:57 AM tacomacc.instructure.com Started: Jan 21 at 2:57pm Quiz Instructions

ID: 3877334 • Letter: 0

Question

00 6:57 AM tacomacc.instructure.com Started: Jan 21 at 2:57pm Quiz Instructions uestion1 1 pts Consider the following non-working implementation of the find method to search for an element in an array: public static int findRecCopy(intl a, in t x) f Courses 28 Groups if (a[b] int index x) return e; findRecCopy (Arrays.copyOfRa nge(a, 1, a. length), x); if (index -1) return -1; return 1index Why doesn't it work? As a comparison, here's a non-recursive method that does work: Inbox public static int findLoop(intl a, int x elp for (int i 0; i

Explanation / Answer

It deos not work because -1 is an invalid index.
Array indexing starts from 0.
The index value will never be -1.