Which of the following is characteristics of an index fossil?

The array a has elements of data type int. The following code is intended to calculate the index of the first?

  • The array a has elements of data type int. The following code is intended to calculate the index of the first occurrence of the value that is least among all the elements of a, and to store that index in the variable minindex. int k; int minindex = 0; for ( k = 1 ; k < a.length ; k++ ) { if ( condition ) statement } Which of the following replacements for condition and statement will cause the code to work as intended? condition statement 1. a[ k ] < minindex minindex = a[ k ]; 2. a[ k ] < a[ minindex ] minindex = a[ minindex ]; 3. a[ k ] < a[ minindex ] minindex = k; 4. a[ k ] > minindex minindex = a[ k ]; 5. a[ k ] < minindex minindex = k; why is it not 2? what is it then? explain! AP's are coming and I want to understand this. Thanks

  • Answer:

    3 minindex contains index of the element which is smallest Assume array contains elements as: 10, 71, 89,2, 99, 2, 200, 16 minindex k a[minindex] a[k] 0 1 10 71 As 71 is not less than 10 minindex will not change 2 89 As 89 is not less than 10 minidnex will not change 3 3 2 2 As 2 is less than 10, minindex becomes 3 4 99 As 99 is not less than 2 minindex willl not change 5 2 As 2 is not less than 2 minindex will not change 6 200 No change in minindex 7 16 No chage in minindex Finally 3 is the index of the element which contains smallest element

Betsy at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.