Exercise 2 solution
"Name That Tune" vs Write Clear Code
Sorting
Algorithm
Find
the minimum value in the list, swap it with the value in the first
position. Repeat the steps above for the remainder of the
list
(starting at the second position and advancing each time).
Algorithm
Each
element is inserted, one at a time, into the sorted list
Searching an array
Sequential
search
Binary
search
A binary search is a
search in which
the array data is repeatedly split in half until the search
key is
found or it is determined that the the search value is not
present.
The data must be sorted on the search key.
The Game: guess a secret number between 1 and 100.
Reference
page
Example 1-13 - Binary Search
Videos
|