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
Rectangle - graphics objects: The other core graphics object is the rectangle that can have curvature added to it (!!). Merely calling the function rectangle without any argum

Run-time or execution-time error: The Run-time, or execution-time, errors are found whenever a script or function is executing. With most of the languages, an illustration of

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

Combining Nested FOR Loops and the IF Statements: The statements inside a nested loop can be any of the valid statement, involving any selection statement. For e.g., there can

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

Example of Function stubs: The three functions have not so far been written, though, therefore the function stubs are put in place so that the script can be executed and teste

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

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 Functions which return values: Calling this function prints the circumference, since there is no way to store the value, hence, it can be used in following computat

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