CS 1337 Lecture Notes - Lecture 2: Selection Sort, Search Algorithm, Binary Search Algorithm
Document Summary
* the efficiency of a search algorithm is based on. * cost of efficiency of sorting, we generally are counting as the binary search is sooooo efficient, we often the number of swaps necessary to get the data sorted. The comparisons are typically not relevant find it an advantage to sort the data before searching especially if we"re going to do a lot of searching. //int main() often ascii value when sorting, we"re talking about some order, typically alphabetical and. * in class, we"re going to start by sorting numbers, using their value. * today we"re sorting integers, meaning we"re using the value. * bubble sort: compare adjacent values through the entire array: compare 17 & 23 proper order so leave alone for all adjacent pairs in array. 17 23 5 11 value: compare 23 & 5 not in proper order so swap them. 17 5 23 11: compare 23 & 11 not in proper order so swap them.