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

Reading from Files: There are many lower level functions which read from files. The function fscanf reads the formatted data into a matrix, by using conversion formats like %s

Illustration of Customizing plots: Illustration, the bar and barh functions by the default place a width of 0.8 between bars. Whenever called as bar(x,y), the width of 0.8 is

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti

Determine sequence weights for the sequences ACTA, ACTT, CGTT, and AGAT in problem 1 by using Thompson, Higgins, and Gibson method a) compute pairwise distances between sequences

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

Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

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

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

Tracing: Sometimes, when a program has loops and/or selection statements and is not running properly, it is helpful in the debugging process to know exactly which statements h