Illustration of binary search, MATLAB in Statistics

Illustration of Binary search:

An illustration to search for the key of 91 in the vector is as shown below:

1451_Illustration of Binary search.png

The table below shows what will happen in each iteration of this search algorithm.

64_Illustration of Binary search1.png

The key found in the fourth element of the vector.

Another illustration: search for the key 82:

494_Illustration of Binary search2.png

The value of low cannot be greater than high; this means that the key is not in the vector. Therefore, the algorithm repeats until either the key is found or until low > high, that means the key is not there.

Posted Date: 10/22/2012 8:01:04 AM | Location : United States







Related Discussions:- Illustration of binary search, Assignment Help, Ask Question on Illustration of binary search, Get Answer, Expert's Help, Illustration of binary search Discussions

Write discussion on Illustration of binary search
Your posts are moderated
Related Questions
Illustration of reading from files: For illustration, suppose that there is a data file 'subjexp.dat' that has on each line a number followed by thecharacter code. The type fu

Program of Persistent variables: The program below elaborates this. The script calls a function func1 that initializes a variable count to 0, then increment it, and print the

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

Operation on file: We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is

WHILE Loops: The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action w

Introduction and Purpose In the lectures and tutorials you have been introduced to a number of probability distributions. You have also learned that modelling any system (such

Example of Core objects: The one core graphics object is a line that is also what the plot function produces. Here is an illustration of generating a line object, altering som

Core Objects: The Core Objects in MATLAB are the very fundamental graphics primitives. The description can be found under the MATLAB Help: Under the Contents tab, click the Ha

Working of Editor and debugger: Editor/Debugger, or commands can be typed from Command Window. For illustration, the dbstop command below will set a breakpoint in the fifth li

Vectorizing: In most of the cases in MATLAB, loops are not essential. As MATLAB is written specifically to work with the vectors and matrices, most operations can be completed