We study searching and sorting algorithms because they appear in the solutions of many problems.
- A professor wants a roster of students who are enrolled in a class. The college’s software sorts the names alphabetically before displaying them on the screen of the professor’s computer.
- A student wants to find a book in the library. The library’s computer searches through a database for books with the title, author, or subject that the student has provided.
- You want to book a flight. You visit a website that searches for flights to your destination and sorts the flights by price.
- A videogame presents a player with an image of a three-dimensional world. The software sorts the objects in the scene from back to front before painting the picture. Like an artist painting with a brush, it paints the distant objects before the near objects. (Or the software might identify sort objects geometrically, so that it can identify the objects it does not have to draw, because they are hidden behind other objects.)
We study searching and sorting algorithms because they are simple. We can produce a program that searches or sorts data by writing just a few lines of code. We can see the whole program at once. We do not have to scroll.
We study searching and sorting algorithms to begin seeing how we can use simple algorithms to build more complex algorithms. You will see searching inside of the sorting algorithms.
We study searching and sorting algorithms computer scientists understand fully. Instructors can explain and beginning students can understand how these algorithms work.
We study searching and sorting algorithms because computer scientists have invented several algorithms for searching and several algorithms for sorting. We can show you more than one way of solving the same problem. We can compare alternatives. We will see criteria and methods for evaluating algorithms. In professional practice, it might not be enough to produce a solution to a problem. The client might want the best solution and a convincing argument that a given solution is better than the alternatives.
The study of algorithms is a large part of computer science. Through a look at several searching and sorting algorithms, we will introduce you to the study of algorithms.