Algorithm for linear search, Data Structure & Algorithms

Assignment Help:

Here,  m represents the unordered array of elements n  represents number of elements in the array and el  represents the value to be searched in the list

Sep 1: [Initialize]

           k=0

           flag=1

Step 2: Repeat step 3 for k=0,1,2.....n-1

Step 3: if (m[k]=el )

               then

              flag=0

               print "Search is successful" and element is found at location (k+1)

               stop

               endif

Step 4: if (flag=1) then

             printf "not successful"

               endif

Step 5: stop


Related Discussions:- Algorithm for linear search

What is an unreachable code assertion, What is an unreachable code assertio...

What is an unreachable code assertion An unreachable code assertion can be placed at the default case; if it's every executed, then program is in an erroneous state. A loop in

Avl tree, Example: (Single rotation into AVL tree, while a new node is inse...

Example: (Single rotation into AVL tree, while a new node is inserted into the AVL tree (LL Rotation)) Figure: LL Rotation The rectangles marked A, B & C are trees

Multiple Queues in a single dimension array, Implement multiple queues in a...

Implement multiple queues in a single dimensional array. Write algorithms for various queue operations for them.

Signals, How does cpu''s part tming and controls generate and controls sign...

How does cpu''s part tming and controls generate and controls signls in computer?

Matrix stored in memory, Method to measure address of any element of a matr...

Method to measure address of any element of a matrix stored in memory. Let us consider 2 dimensional array a of size m*n further consider that the lower bound for the row index

Registers, what are registers? why we need register? Definition? Types? Wha...

what are registers? why we need register? Definition? Types? What registers can do for us?

What are the properties of colour, Properties of colour Colour descript...

Properties of colour Colour descriptions and specifications generally include three properties: hue; saturation and brightness. Hue associates a colour with some position in th

Determine the effect of ruby in implementation of string, Determine the eff...

Determine the effect of Ruby in implementation of string Ruby has a String class whose instances are mutable sequences of Unicode characters. Symbol class instances are charact

Array implementation of lists, In the array implementation of the lists, we...

In the array implementation of the lists, we will use the array to hold the entries and a separate counter to keep track of the number of positions are occupied. A structure will b

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd