Question: Binary search is such an efficient searching algorithm because during each pass of the loop (in the iterative version) or in each method call (in
Binary search is such an efficient searching algorithm because during each pass of the loop (in the iterative version) or in each method call (in the recursive version) the size of the list is essentially halved (an algorithm which repeatedly divides the problem size by two each time will have O(lg n) performance). If reducing the size of the list to be searched by two is so efficient, it may seem that dividing the problem size by three each time would be even faster. To that end, consider this ITERATIVE ternary (ternary is base three) search method. Rewrite it is as RECURSIVE ternary search method named int recTernarySearch(ArrayList pList, Integer pKey, int pLow, int pHigh). 
int ternarySearch (ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
