Question
My roommate has bought a pair of rabbits, Rowena and Salazar. We kept track of the number of offsprings every month in vector, r. We
My roommate has bought a pair of rabbits, Rowena and Salazar. We kept track of the number of offsprings every month in vector, r. We want to write an algorithm to find if given a number, q N, is in r. For instance, given the following sets, elements of q1 exist in r, whereas elements of q2 do not.
r = {1, 2, 3, 5, 8, 13, 21, 34} q1 = {2, 21, 34}
q2 = {5, 15, 35}
Write a recursive algorithm to solve the problem given above for any ordered set that uses the design technique discussed in class. If the query is found, return its index, otherwise, return 1. Your algorithm will be called using:
findFluffy( r, 0, r.length, query)
findFluffy(r, min, max, query) {
}
Calculate the time complexity of your approach.
T(n) =
(n) =
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