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
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

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

Sorting Strings: For the matrix of strings, the sort function works exactly as formerly for numbers. For illustration, >> words = char('Hi', 'Hello', 'Howdy', 'Goodbye', '

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

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

Help function: Function is computing the two values, there are two output arguments in the function header (i.e., area & circum), that are placed in the square brackets [ ]. A

Properties of the text box - graphics objects: By using get will show properties of the text box, the illustration is as shown below: >> get(thand)   BackgroundColor

Illustration of Indexing into vectors of structures: For illustration, the function to print the information from packages has been modified therefore in addition to the vecto

Example of sorting strings: To sort a cell array of strings, also the sort function is used. The illustration is as follows, >> engcellnames = {'Chemical','Mechanical',.

Logical Built-In Functions: There are built-in functions in the MATLAB which are useful in conjunction with vectors or matrices of all logical true or false values; two of the