Illustrations of sequential search, MATLAB in Statistics

Illustrations of Sequential search:

The two illustrations of calling such function is as shown below:

>> values = [85 70 100 95 80 91];

>> key = 95;

>> seqsearch(values, key)

ans =

    4

>> seqsearch(values, 77)

ans =

    0

This illustration supposes that the key is found only in one element in the vector. Also, however it works; it is not a very efficient algorithm. When the vector is large, and the key is found in the starting, this still loops through the rest of the vector. The improved version would loop until the key is found or the whole vector has been searched. In another words, a while loop is used instead of a for loop; there are two sections to the condition.

46_Illustrations of Sequential search.png

Posted Date: 10/22/2012 7:57:51 AM | Location : United States







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

Write discussion on Illustrations of sequential search
Your posts are moderated
Related Questions
function sortrows - sorting strings: The function sortrows sorts each and every row as a block, or group, and it also will work on numbers. Here in this illustration the rows

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

Function polyval - interpolation: The function polyval can then be used to compute the polynomial at particular values. For illustration, we could compute at every value in th

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

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

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

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

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

Indexing: The Indexing is an alternate to sort a vector. With indexing, the vector is left in its original order. An index vector is used to point values in the original vecto

Nested Functions: We have seen that the loops can be nested, that means that one inside of the other, functions can be nested. The terminology for nested functions is that an