0

A question asked in Oracle interview "find missing element in a sorted array of n element ranges 1 to n without accessing full array". I am wondering if there is a way to find missing element without accessing all the element ? There is only one element is missing and no repetition. Plz help me if there is a solution to this question .

asked Feb 11, 2014 at 15:13

1 Answer 1

2

You do a slightly customized binary search. You access the n/2st element and look at the value. If it is smaller than n/2, your missing element is in the lower half of the array. Else in the upper. Then you do the same in the lower half. And continue that until you are at only one possibility. Works on sorted arrays with random access in O(log(n)).

answered Feb 11, 2014 at 15:18
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.