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

Linked list, Write a program for reversing the Linked list

Write a program for reversing the Linked list

Explain best - fit method, Best - Fit Method: - This method obtains the sma...

Best - Fit Method: - This method obtains the smallest free block whose  size is greater than or equal to get such a block by traversing the whole free list follows.

Hash clash, Q. What do you understand by the term by hash clash? Explain in...

Q. What do you understand by the term by hash clash? Explain in detail any one method to resolve the hash collisions.

Define the external path length, Define the External Path Length The Ex...

Define the External Path Length The External Path Length E of an extended binary tree is explained as the sum of the lengths of the paths - taken over all external nodes- from

Representation of sets?, A set s is conveniently shown in a computer store ...

A set s is conveniently shown in a computer store by its characteristic function C(s). This is an array of logical numbers whose ith element has the meaning "i is present in s". As

Logic circuits, the voltage wave forms are applied at the inputs of an EX-O...

the voltage wave forms are applied at the inputs of an EX-OR gate. determine the output wave form

Make adjacency matrix for un-directed graph, Q. Describe the adjacency matr...

Q. Describe the adjacency matrix and make the same for the given undirected graph.    Ans: The representation of Adjacency Matrix: This representation consists of

Present the algorithm of binary search. , B i n a ry Search Alg...

B i n a ry Search Algorithm is given as follows 1. if (low > high) 2.     return (-1) 3. mid = (low +high)/2; 4. if ( X = = a [mid]) 5.      return (mid); 6.

State in detail about the integer, State in detail about the Integer ...

State in detail about the Integer Carrier set of the Integer ADT is the set {..., -2, -1, 0, 1, 2, ...}, and  operations on these values are addition, multiplication, subtrac

A bst is traversed in which order recursively, A  BST is traversed in the ...

A  BST is traversed in the following order recursively: Right, root, left e output sequence will be in In Descending order

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