Question: 9 . Refer to method search. / * * @param v an initialized array of integers * @param key the value to be found *
Refer to method search.
@param v an initialized array of integers
@param key the value to be found
Postcondition:
Returned value k is such that k vlength
If k then vk key.
If k then key any of the elements in v
public static int searchint v int key
int index ;
while index vlength && vindex key
index;
if vindex key
return index;
else
return ;
Assuming that the method works as intended, which of the following should be
added to the precondition of search?
A v is sorted smallest to largest.
B v is sorted largest to smallest.
C v is unsorted.
D There is at least one occurrence of key in v
E key occurs no more than once in v
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
