O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Binary Search Using Recursion

Recall from Chapter 11, “Arrays Part II: Multidimensional Arrays. Searching and Sorting Arrays,” how we used the binary search technique to locate a number in a sorted array of numbers. The implementation in Chapter 11 made use of iteration. In this section, we will use the same basic ideas of binary search, but this time implemented with a recursive method. Because the underlying ideas are the same whether we use iteration or recursion, you might want to revisit the binary search section in Chapter 11 before beginning the recursion example described next.

The binary search technique can be viewed as a series of searches where each search is a smaller version of the previous search. Each search can briefly be described ...

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