(100 pts) Write a program to find the smallest positive integer that (loes not a
ID: 645997 • Letter: #
Question
(100 pts) Write a program to find the smallest positive integer that (loes not appear in the array and can not be formed by the sum of two numbers in an array. For this assignment implement the following function mt issumof2(int data[], mt size, mt number) mt inarray((int data[], mt size, mt number) The function issumof2 returns 1 if the number is sum of 2 elements in the array data and returns 0 otherwise. size is the number of elements in the array. The function murray returns 1 if the number appears in the array data and returns 0 otherwise. size is the number of elements in the array. 1 2 1 2 1 3 1 4 1 3 1 1 0 1 2 3 4 5 6 Figure 1: Example An example is given in figure 1. 1,2.3 and 4 appear in this array. 4 can be formed as 4 + 1, 5 as 3 + 2, 6 as 3 + 3 , 7 as 3 + 4 and 8 as 4 + 4 (it is ok to use a number twice). 9 does not appear in the array and it can not be formed as sum of 2 numbers in the array. So, 9 is the solution for this array. Read an array of size 7 from the user, compute the smallest positive integer that does not appear in the array or can not lie formed by the stun of two numbers in an array. and print the result. Sample execution is given below Enter 7 numbers 1223431 Smallest Nonpositive Integer = 9Explanation / Answer
Pass 1, move every value to the position of its value for cursor in range(N): target = array[cursor] while targetRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.