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

What do you mean by invalid pointer arithmetic?

857


What is the acronym for ansi?

842


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1785


What are the types of c language?

814


What is indirection in c?

843


Is a pointer a kind of array?

869


write a c program to calculate sum of digits till it reduces to a single digit using recursion

3035


What is a null pointer in c?

883


What is character set?

950


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15478


Explain how do you use a pointer to a function?

887


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

937


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

890


What is meant by inheritance?

886


What is the function of volatile in c language?

904