Complete the body of deepEquals FronPostoEnd so it satisfies its contract. For e
ID: 3723857 • Letter: C
Question
Complete the body of deepEquals FronPostoEnd so it satisfies its contract. For example, if anda 2.3 arr2 |2,2,3,4, and pos 2; then the method returns TRUE. Alternatively, if arr1-(1,2,3,41, arr2 (2,2,3,A, and pos 0; then the method returns FALSE. For full credit, you must use recursion and only one return stat 4. Reports if two Natural Number arrays are equal, element-wise from array index [pos] to the end of the arrays.... erequires arri.length arr2.1ength 88 ec- pos and pos arri.length eensures deepEqualsFromPosToEnd [if the arrays are equal from pos t the end ) private static boolean deepEqualsFromPosToEnd (NaturalNumber [1 arr1, NaturalNumber [1 arr2, int pos)fExplanation / Answer
private static boolean deepEqualsFromPosToEnd(NaturalNumber[] arr1, NaturalNumber[] arr2, int pos)
{
if(pos < arr1.length)
{
return arr1[pos].equals(arr2[pos]) && deepEqualsFromPosToEnd(arr1, arr2, pos+1);
}
else
return true;
}
Note: You have not given the class definition of NaturalNumber. I have assumed there is an equals() method defined in it.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.