To search an ordered list a Binary Search is the best way, however the list needs to be put into that order in the first place, this is where the Insertion Sort comes in.
It consists of a number of passes thought the data and is quicker than a bubble sort
- Starts by taking out the second item and comparing it to the items to the left of it, If they need to be moved then they are
- Then looks at the third item and does the same
- And so an and so fourth until its completed
Prodedure Sort (List, First, Last)
For CurrentPointer = First + 1 To Last
Current Value = List[CurrentPointer]
Pointer = CurrentPointer - 1
While List[Pointer] > CurrentValue and Pointer > 0
List[Pointer+1] = List[Pointer]
etc...
Comments
Report