Question

**Problem five:**

**Design an algorithm called which searches for a target t
in the sorted subarray , returning the appropriate index if t is
found, and 0 if t is not found. TenarySearch will work by dividing
the input array into three subarrays of approximately equal length,
and calling itself recursively on each subarray.**

**a. Write pseudo-code for TernarySearch.**

**b. Write down the recurrence for the run time of
TernarySearch and find a tight asymptotic bound on its
solution.**

Answer #1

`Hey,

**Note: If you have any queries related to the answer
please do comment. I would be very happy to resolve all your
queries.**

**1)**

Begin if start <= end then midFirst := start + (end - start) /3 midSecond := midFirst + (end - start) / 3 if array[midFirst] = key then return midFirst if array[midSecond] = key then return midSecond if key < array[midFirst] then call ternarySearch(array, start, midFirst-1, key) if key > array[midSecond] then call ternarySearch(array, midFirst+1, end, key) else call ternarySearch(array, midFirst+1, midSecond-1, key) else return invalid location End

**2)**

**T(n)=T(n/3)+1**

**So, T(n)=theta(log(n))**

**Kindly revert for any queries**

**Thanks.**

Take a look at the file GenericMethods.java.
There are three methods you must implement:
·public static <T extends
Comparable<T>> int findMin(T[] arr): Iterate through the
array to find the index of the smallest element in the array. If
there are two elements with the smallest value, the method should
return the index of the first one. The method should run in
O(n).
·public static <T extends
Comparable<T>> int findMinRecursive(T[] arr): Should
behave just like findMin, but should be implemented
recursively....

Task 2: Compare strings. Write a function compare_strings() that
takes pointers to two strings as inputs and compares the character
by character. If the two strings are exactly same it returns 0,
otherwise it returns the difference between the first two
dissimilar characters. You are not allowed to use built-in
functions (other than strlen()) for this task. The function
prototype is given below: int compare_strings(char * str1, char *
str2);
Task 3: Test if a string is subset of another...

Using the model proposed by Lafley and Charan, analyze how
Apigee was able to drive innovation.
case:
W17400
APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF
GROWTH
Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote
this case solely to provide material for class discussion. The
authors do not intend to illustrate either effective or ineffective
handling of a managerial situation. The authors may have disguised
certain names and other identifying information to protect
confidentiality.
This publication may not be...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 4 minutes ago

asked 5 minutes ago

asked 8 minutes ago

asked 28 minutes ago

asked 42 minutes ago

asked 42 minutes ago

asked 43 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago