ENGR 101 Lecture 21: 21LectureNotes
Document Summary
Often sequences of data are more useful if the elements are in order. Rearranges a data sequence so that the elements are in order. Is a very common and useful category of algorithms. Go through the list, swapping adjacent places when out of order. Ensures that the highest gets to the end. Then go through the list again, swapping as we go . Ensures that the second highest is second to the end. Create new sorted list by going through input list one-by-one. For each input item, go through new list in order, stop and insert in place that would maintain order. Suppose we are looking for value in a sorted vector, a. Compare the value against the middle element of a and there are three possibilities: Value is equal to the middle element. If it"s case 1, we"re done and the index of the value was found.