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 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',.

Nested for Loops: The action of a loop can be any of the valid statement(s). Whenever the action of a loop is the other loop, this is known as nested loop. As an illustrati

Illustration of Median When the vector is not in sorted order to start with, the median function will still return the right answer (it will sort the vector automatically). For

fopen function - file function: The fopen opens the file for reading. The fscanf then reads each line one double and one character, and put each pair in individual columns in

Functions which return Values versus printing: Also, the function which computes and returns values (throughout the output arguments) does not generally print them; that is le

Example of customizing plots: As the other illustration of customizing plots, the pieces of a pie chart can be "exploded" from the rest. In this situation, the two vectors are

Curve Fitting: The data is fundamentally either discrete or continuous. In most of the applications, data is sampled, for illustration, The temperature recorded every ho

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

Example of Median For the vector [1 4 5 9 12 33], the median is the average of the 5 & 9 in the middle: >> median([1 4 5 9 12 33]) ans =     7