O'Reilly logo

Everyday Data Structures by William Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

In this chapter, we examined several search algorithms. First, we looked at linear searching, or sequential searching. Linear searching is barely even an algorithm as your code is simply looping through the elements in a collection from left to right until a match is found. This approach is useful when working with very small collections, or with collections that have not been sorted, if for no other reason than it is easy to implement from a development point of view. However, when working with large sorted datasets, there are much better alternatives.

The next search algorithm we examined was the binary search. Binary search algorithms essentially divide-and-conquer the collection, halving the elements into smaller and smaller subsets ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required