Chapter 13

Sorting and Searching

Some of the most fundamental things that we do on computers are to order data according to certain values and to search through data for various things. These activities are known as sorting and searching, respectively. Due to their importance in solving many different types of problems, a lot of work has gone into doing them as quickly and efficiently as possible. In this chapter we will start your exploration of the topics by working through some of the simpler approaches.

13.1 Basic Comparison Sorts

There are many different ways in which to sort data. The most general ones do not have many requirements on the nature of the data. All they require is the ability to compare elements to see if one should come before ...

Get Introduction to the Art of Programming Using Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.