There are a number of different search algorithms that you can use.
Some of them depend on how you are storing the data. Most of them use some sort of loop...including for loops.
If you want to do a sequential search, you loop through every item starting at index 0 and going to the length of the items.
Pseudo code example:
- let biggestValue be 0
-
let currentIndex be 0
-
-
begin loop
-
get the item at the current index
-
if the current item is bigger than the biggestValue
-
Set the biggestBiggestValue to the current item
-
otherwise, do nothing
-
increase the current index
-
if the index is greater than the length of the items, exit the loop
-
loop
Here is an example of a For...Next loop in vb syntax:
-
Dim currentIndex As Integer
-
Dim maxIndexOfList As Integer
-
maxIndexOfList = 9
-
-
For currentIndex = 0 to maxIndexOfList Step 1
-
'get the item at the current index
-
'if the current item is bigger than the biggestValue
-
' Set the biggestBiggestValue to the current item
-
'otherwise, do nothing
-
-
'note that the currentIndex is automatically incremented by the "step" value provided
-
'note if no Step is provided, it is assumed to be 1
-
-
'note that the loop will end when the currentIndex value is greater than the maxIndexOfList value
-
Next
-Frinny