Chapter 1. Introduction to algorithms / 3

Running time Any time I talk about an algorithm, I’ll discuss its running time. Generally you want to choose the most efficient algorithm whether you’re trying to optimize for time or space. Back to binary search. How much time do you save by using it? Well, the first approach was to check each number, one … Continue reading Chapter 1. Introduction to algorithms / 3

Chapter 1. Introduction to algorithms / 2

Let’s see how to write binary search in Python. The code sample here uses arrays. If you don’t know how arrays work, don’t worry; they’re covered in the next chapter. You just need to know that you can store a sequence of elements in a row of consecutive buckets called an array. The buckets are … Continue reading Chapter 1. Introduction to algorithms / 2

Chapter 1. Introduction to algorithms / 1

In this chapter• You get a foundation for the rest of the book.• You write your first search algorithm (binary search).• You learn how to talk about the running time of an algorithm (Big O notation).• You’re introduced to a common technique for designing algorithms (recursion). Introduction An algorithm is a set of instructions for … Continue reading Chapter 1. Introduction to algorithms / 1