Searching and Sorting Arrays
Chapter 8
Searching an Array for a Specific Item
Sequential search (or linear search):
Searching a list for a given item, starting from the first array element
Compare each element in the array with the value being searched for
Continue the search until the item is found or no more data is left in the list.
Sorting an Array
Selection sort is one algorithm that orders a list by moving unsorted values to their proper position.
Steps:
- Find the smallest element in the unsorted portion of the list.
- Swap it with the top value in the unsorted portion of the array.
- Start again with the rest of the list.