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
fscanf function - file function: The fscanf reads matrix variable mat columnwise from the file specified by fid. The 'format' involves conversion characters much similar to th

Functions which complete a task without returning Values: Most of the functions do not compute values, but instead of accomplish a task like printing formatted output. As thes

Mode The mode of a data set is the value which appears most often. The built-in function in a MATLAB for this is known as the mode. >> x = [9 10 10 9 8 7 3 10 9 8 5 10];

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

Variable packages: Variable packages are now the vector of structures, hence each and every element in the vector is a structure. To show one element in the vector, an index i

Illustration of Binary search: An illustration to search for the key of 91 in the vector is as shown below: The table below shows what will happen in each iteration of

Areacirc function: The areacirc function can be called from the Command Window as shown here, or from a script. Here is a script which will prompt the user for the radius of o

Need of a nested loop: How would we sum each individual column, rather than getting an overall sum? Answer: The programming technique would need a nested loop in whi

Editor/Debugger: The MATLAB has numerous useful functions for debugging, and debugging can also be completed through its editor, which is known as the Editor/Debugger. Typi

Graphics objects: The objects involve graphics primitives like lines and text, and also the axes used to orient the objects. These objects are organized hierarchically, and the