Question
Write a recursive method that tries to find target among the elements a[m],...,a[n-1] of a given array (any array, not necessarily sorted). public static int
Write a recursive method that tries to find target among the elements a[m],...,a[n-1] of a given array (any array, not necessarily sorted).
public static int search (int[] a, int m, int n, int target)
If found, the method should return the position of the target value; otherwise it should return -1. The base case is when the searching range is empty or consists of one element (m n). For the recursive case, split the searching range into two approximately equal halves and try to find the target in each of them. (this is supposed to be written in Java)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started