Basic Sorting Algorithms

Michael McMillan · Cambridge University Press eBooks · 2005

The two most common operations performed on data stored in a computer are sorting and searching. This has been true since the beginning of the computing industry, which means that sorting and searching are also two of the most studied operations in computer science. Many of the data structures discussed in this book are designed primarily to make sorting and/or searching easier and more efficient on the data stored in the structure. This chapter introduces you to the fundamental algorithms for sorting and searching data. These algorithms depend only on the array as a data structure and the only “advanced” programming technique used is recursion. This chapter also introduces you to the techniques we'll use throughout the book to informally analyze different algorithms for speed and efficiency. SORTING ALGORITHMS Most of the data we work with in our day-to-day lives is sorted. We look up definitions in a dictionary by searching alphabetically. We look up a phone number by moving through the last names in the book alphabetically. The post office sorts mail in several ways—by zip code, then by street address, and then by name.Sorting is a fundamental process in working with data and deserves close study. Although researchers have developed some very sophisticated sorting algorithms, there are also several simple sorting algorithms you should study first. These sorting algorithms are the insertion sort, the bubble sort, and the selection sort. Each of these algorithms is easy to understand and easy to implement.

Read the paper · More papers on PaperTik