This preview shows page 1. Sign up to view the full content.
Unformatted text preview: binary search algorithm, a faster searching algorithm that we can use if we know the list is sorted and the implementation is array based. 9.4 Sorting We all know what sorting is. We sort our sock drawers, our bookshelves, even our priorities. Sorting is putting things in order. In computing, trans-forming an unsorted list into a sorted list is a common and useful opera-tion. Whole books have been written about various sorting algorithms, as well as algorithms for searching a sorted list to find a particular element. The goal is to come up with better, more efficient, sorts. Because sorting a large number of elements can be extremely time-consuming, a good sorting algorithm is very desirable. This is one area in which programmers are sometimes encouraged to sacrifice clarity in favor of speed of execution. IsThere(item) Set tempItem to the first item While ( more items ) If (tempItem.compareTo(item) is equal to 0) return true Else Set tempItem to next item Return false...
View Full Document
- Fall '10