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
Advanced File Input and output: Where 'format' involves the conversion characters much like those used in the fprintf function. For illustration, to read the file 'subjexp.dat

Need of a nested loop: How would we sum each individual column, rather than getting an overall sum? Answer: The programming technique would need a nested loop in whi

Input in a While Loop: The script below repeats the procedure of prompting a user, the reading in a positive number, and echo-printing it, as long as the user properly enters

Illustration of Nested loops: Running the script shows the output: >> printstars ***** ***** ***** The variable rows identifies the number of rows to print, and

Illustration of Mode When there is more than one value with similar (highest) frequency, then the smaller value is mode. In the case below, as 3 and 8 appear twice in the vecto

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

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

Statistics There are numerous statistical analyses which can be executed on data sets. In MATLAB software, the statistical functions are in the data analysis help topic known a

The IF Statement: The if statement selects whether or not the other statement, or group of statements, is executed. The common form of the if statement is as shown below: i

Illustration of nested for loops and the if statements: For illustration,when the file contains: 33   -11  2  4      5   9 22     5  -7  2     11    3 the outco