This preview shows page 1. Sign up to view the full content.
Unformatted text preview: design of algorithms and use it to develop an algorithm called merge sort. We end with an analysis of merge sort’s running time. 2.1 Insertion sort Our ﬁrst algorithm, insertion sort, solves the sorting problem introduced in Chap-ter 1: Input: A sequence of n numbers ± a 1 , a 2 ,... , a n ² . Output: A permutation (reordering) ± a ³ 1 , a ³ 2 , ... , a ³ n ² of the input sequence such that a ³ 1 ≤ a ³ 2 ≤ ··· ≤ a ³ n . The numbers that we wish to sort are also known as the keys . In this book, we shall typically describe algorithms as programs written in a pseudocode that is similar in many respects to C, Pascal, or Java. If you have been introduced to any of these languages, you should have little trouble reading our al-gorithms. What separates pseudocode from “real” code is that in pseudocode, we...
View Full Document
This document was uploaded on 11/22/2010.
- Fall '09