Please Help. Describe an algorithm that upon input of n real numbers denoted al5
ID: 2971434 • Letter: P
Question
Please Help.
Explanation / Answer
(a).
Let us assume that the n real numbers are provided in the form an array
let the numbers in an array of double data type of size n ---> double Array[ n ]
for ( i=0 ; i<n ; i++ )
{
if( Array[ i ] > x )
printf(" %f is strictly grater than x " , Array[ i ]);
}
(b).
In the above algorithm the entire array is traversed one time and the size of the array is equal to 'n'
So , it's complexity is of the order n i.e., O( n )
(c).
a,b,c are of order O(x^2)
d,e are not O(x^2)
(d).
k5
[0, 1, 1, 1, 1]
[1, 0, 1, 1, 1]
[1, 1, 0, 1, 1]
[1, 1, 1, 0, 1]
[1, 1, 1, 1, 0]
k2,3
[0 0 1 1 1]
[0 0 1 1 1]
[1 1 0 0 0]
[1 1 0 0 0]
[1 1 0 0 0]