Question: You are given as input an array A [ 1 . . . n ] , with n entries. The array consists of a series
You are given as input an array An with n entries. The array consists of a series of s followed by a series of s but you dont know how many of each there are. Your goal is to find the first in the array. There is a cost associated with checking the value of an array. Each time you check a value and it turns out to be you must pay dollar. If value turns out to be you have to pay euro. In each of the parts of this question, you will have some number of dollars and some number of euros. You must give an algorithm which will return the index of the first lowest index occurrence of which works given your resources. Justify that your algorithm does not use more than the given amount of dollars and euros. Now consider the case where you are given an array A but you dont know its size n Again, you want to find the first in the array. Suppose this first is at some location t and of course you dont know the value of t Give an algorithm that solves the problem using Osqrtt dollars and euros.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
