if array a conatins 'n' elements and array b conatins 'n-1'
elements.array b has all element which are present in array
a but one element is missing in array b. find that
element.
Answer Posted / argho chatterjee
// Assuming arrays are sorted in ascending order
/*
it is not efficient if the number is found at the start of
the array.
It tries to break the array and find the position from the
middle and then again breaks till it find the position of
the array.
*/
public static void main(Array mainArray , Array
missingArray) {
int pointer = mainArray.length /2; // default is 0
return findMissingElement
(mainArray ,missingArray,pointer);
}
int findMissingElement(Array mainArray , Array
missingArray,pointer) {
if(mainArray[pointer] ==
missingArray[pointer] ) {
pointer = pointer + pointer /2;
return
findMissingElement
(mainArray ,missingArray,pointer);
}
else {
return mainArray[mainArray.length/i];
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain how do you determine whether to use a stream function or a low-level function?
What is a void * in c?
what is the function of pragma directive in c?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Can we assign string to char pointer?
What is a constant and types of constants in c?
How can I call a function with an argument list built up at run time?
What's the difference between constant char *p and char * constant p?
Explain the Difference between the New and Malloc keyword.
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
Differentiate abs() function from fabs() function.
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
Explain the difference between malloc() and calloc() function?
how could explain about job profile
will u please send me the placement papers to my mail???????????????????