Question: Consider an array Age with n elements representing the ages of individuals within a group in arbitrary order The following algorithm (given in Java-like pseudocode)

 Consider an array Age with n elements representing the ages of

Consider an array Age with n elements representing the ages of individuals within a group in arbitrary order The following algorithm (given in Java-like pseudocode) outputs indexes of two individuals that are the closest in age among pairs of individuals whose ages are stored in the array. Note that if there is more than one pair of individuals with the same age difference we simply return one such pair. In the code below, abs(x) computes the absolute value of x. For example, if Age[-25; Age(1-50; Age[2]=15; Age[3]=52, the algorithm will output 1 and 3 since individual 1 and 3 have age difference equals to 2, while any other pair of individuals have larger age difference CSI 2110 page 2 2. int mnDifference=abs (Age [0-Age[1]); 3. for (i-0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!