Wrapping Up
Often there’s more than one way to achieve a particular computing goal, and the algorithm you choose can seriously affect the speed of your code.
It’s also important to realize that there usually isn’t a single data structure or algorithm that is perfect for every situation. For example, just because ordered arrays allow for binary search doesn’t mean you should always use ordered arrays. In situations where you don’t anticipate the need to search the data much but, instead, to add data, standard arrays may be a better choice because their insertion is faster.
As we’ve seen, the way to analyze competing algorithms is to count the number of steps each one takes. In the next chapter, we’re going to look at a formalized way of expressing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access