English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

in the array?

A coded example would be great.

2007-03-09 04:35:05 · 2 answers · asked by roslya 1 in Computers & Internet Programming & Design

2 answers

ok try this

int minValue = yourArray[i]; //Assume first one is smallest
for(int i=1; i {
if(minValue > yourArray[i])
{ minValue = yourArray[i]; }
}

its the simplest method to do it

2007-03-09 04:48:01 · answer #1 · answered by quiksilver_army 2 · 0 0

int lowest = array[0];

for(int i=1; i if(array[i] < lowest)
lowest = array[i];

Runs in O(n).

You should look into an algorithm called "Select" for the most efficient way to do this. This algorithm is capable of finding the i-th lowest element in a list very quickly.

2007-03-09 13:32:24 · answer #2 · answered by icnintel 4 · 0 0

fedest.com, questions and answers