Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please give answer each of the question You are given an array containing N distinct integers in ascending order. You have to find out the

please give answer each of the question
You are given an array containing N distinct integers in ascending order. You have to find out the
first missing number from the increasing sequence.
For example: [3,4,5,6,9,10]. The first missing number in this sequence is 7.
[Explanation : If A and are two consecutive integers from the list and their difference
i
A
i+1
(A is more than 1, then we say +1 is a missing number.]
i+1 A
i
) A
i
Now that you have understood the problem completely, you are trying to solve it efficiently. Your
friend, Jack, said that by iterating through all the numbers from the beginning, you can find the first
missing number in linear time [O(N)]. But, you need a more efficient one. Now, answer the
questions below.
a) If N =9 and the maximum number (obviously the last-indexed one) in the array is 15,
which one among 6,8,10 might be the first number (obviously the minimum one) in the
array?
b) Explain why you discarded the other two numbers in question no.(a).
01
01
c) Assume N =7 and the minimum and maximum numbers are 2 and 12 respectively. You
found the middle-index value to be 5. On which side (left/right) of 5, do you expect to find
the first missing number? Only mention left or right.
d) Explain why you discarded the other half of the array in question no.(c).
e) Assume N =7 and the minimum and maximum numbers are 8 and 19 respectively. The
missing elements are 11,13,14,17,18. What will be the value of the middle-index
element? Determine the absolute difference between the middle-index value and the
maximum number.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

3. Maximize (the agreement function).

Answered: 1 week ago