Describe how the pair-wise summation computation provided below can be changed to find the maximum element of an array. Array has the following elements (x[0], x[1], x[2], x[3], x[4], x[5], x[6])
t[0] = x[0] + x [1];
t[1] = x[2] + x[3];
t[2] = x[4] + x[5];
t[3] = x[6] + x[7];
t[4] = t[0] + t[1];
t[5] = t[2] + t[3];
sum = t[4] + t[5];

Respuesta :

Answer:

To change the pair-wise summation computation provided  to find a maximum element of an array we; Take two elements to check max element from that and add to the T ARRAY, the same process is then repeated for the next two elements, again we repeat the same process for the next two elements from T array until we get the max element  process going on pair-wise computation

Explanation:

Code written using pair-wise computation to describe how to change the given pair-wise summation computation provided to find the maximum element of an array

The given array element ; (x[0], x[1], x[2], x[3], x[4], x[5], x[6])

IF X[0] > X[1]

T[0]=X[0];

ELSE

T[0]=X[1]

IF X[2] > X[3]

T[1]=X[2];

ELSE

T[1]=X[3];

IF X[4] > X[5]

T[2]=X[4];

ELSE

T[2]=X[5];

T[3]=X[6];

IF T[0] > T[1]

T[4]=T[0];

ELSE

T[4]=T[1]

IF T[2] >T[3]

T[5]=T[2];

ELSE

T[5]=T[3];

IF T[4] > T[5]

MAX=T[4];

ELSE

MAX=T[5]