Chapter 7

Arranging and Searching Data

IN THIS CHAPTER

Bullet Performing sorts using merge sort and quick sort

Bullet Conducting searches using trees and the heap

Bullet Considering the uses for hashing and dictionaries

This chapter is about using the four data operations — create, read, update, and delete (CRUD) — to manage data. The first section of this chapter focuses on sorting data. Placing data in an order that makes it easy to perform CRUD operations is important because the less code you need to make data access work, the better. In addition, even though sorting data might not seem particularly important, sorted data makes searches considerably faster, as long as the sort matches the search. Sorting and searching go together: You sort the data in a way that makes searching faster.

The second section of the chapter discusses searching. You won’t be surprised to learn that many different ways are available to search for data. Some of these techniques are slower than others; some have attributes that make them attractive to developers. The fact is that no perfect search strategy exists, but the exploration for such a method continues.

The final section of the chapter looks at hashing and dictionaries. ...

Get Algorithms For Dummies, 2nd Edition 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.