Purchase Solution

Detailed explanation of a binary search in Java

Not what you're looking for?

Ask Custom Question

Examine the BinSearch.java program. Write a Word or text document detailing how the binary search code works.

Text document ok.

See the attached file.

Attachments
Purchase this Solution

Solution Summary

In this solution I provide a detailed explanation of how a binary search works. This includes a complete example and illustration using a Java implementation of the binary search.

Solution Preview

The basic idea of a binary search is fairly straight-forward. You start with an ordered list of elements and an element to search for in that list. Then you look at the middle element of the list, if it matches the search element you are done. If the middle element is larger than the search element then you know that you only need to search the first half of the list for the element (since if the search element is in the list and the list is ordered it will be in all of the elements lower than the middle). At this point you repeat the procedure pretending that the first half of the list is the entire list that you have. That is, you look at the middle of the new list (the first half of the old list) and look for a match and so on. You repeat this process until ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Javscript Basics

Quiz on basics of javascript programming language.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.