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

How is a structure member accessed?

849


Compare array data type to pointer data type

832


How do you print an address?

993


Can the “if” function be used in comparing strings?

794


What are shell structures used for?

806


What is a union?

810


What does the && operator do in a program code?

962


Write a program for Overriding.

930


How to delete a node from linked list w/o using collectons?

2397


What is c language & why it is used?

791


How do you redirect a standard stream?

869


What does do in c?

801


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

878


why return type of main is not necessary in linux

1891


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

905