Purchase Solution

binary search

Not what you're looking for?

Ask Custom Question

What is a binary search, and how does it work?

Purchase this Solution

Solution Summary

This job defines a binary search.

Solution Preview

Binary Search is arguably one of the most useful algorithms you will come across. It accepts a sorted list of numbers, a single integer value x as input, and returns the xth greatest number in the list.

For example, consider the following sorted list of ten integers:
1, 2, 3, 4, 6, 8, 9, 10, 12, 15

Say that we are looking to see if 12 is in the list. First, look at the middle value in the list. We can find this by looking at the indices of the first and last elements. Since we have a list of ten numbers, we look for the element in position (1+10)/2 = 5.5. In our list, this is the number 6. We ...

Purchase this Solution

Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.