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


Please Help Members By Posting Answers For Below Questions

When should the volatile modifier be used?

689


Process by which one bit pattern in to another by bit wise operation is?

617


how to write optimum code to divide a 50 digit number with a 25 digit number??

2757


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

646


What is the difference between arrays and pointers?

638






What's a good way to check for "close enough" floating-point equality?

632


What is null character in c?

695


What is spaghetti programming?

674


What is the use of bit field?

648


What does the c in ctime mean?

573


How can I call a function with an argument list built up at run time?

646


how do you programme Carrier Sense Multiple Access

1523


Why main is not a keyword in c?

653


In C programming, what command or code can be used to determine if a number of odd or even?

627


Are pointers integers in c?

615