answersLogoWhite

0

Flowchart for linear search

Updated: 12/22/2022
User Avatar

Wiki User

12y ago

Best Answer

PROGRAM:

//LINEAR SEARCH USING FUNCTIONS

#include

void linear(int [],int,int);

main()

{

int n,i,x,a[10];

printf("\nEnter the limit:");

scanf("%d",&n);

printf("\nEnter the elements:");

for(i=0;i

{

scanf("%d",&a[i]);

}

printf("\nEnter the element to be searched:");

scanf("%d",&x);

linear(a,n,x);

}

void linear(int a[],int n,int x)

{

int i,flag=0;

for(i=0;i

{

if(x==a[i])

{

flag=1;

break;

}

}

if(flag==1)

printf("\nElement %d is in the position %d",a[i],i+1);

else

printf("\nElement is not in the list");

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Flowchart for linear search
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you make a flowchart for 'hello world'?

( start ) -> / Write "Hello World" / -> ( end ) *try to search an example on google. *type "flowchart of hello world"


Explain linear search with an example?

Sequential search of an object with in an array of objects is called as linear search.


What is linear searching?

The linear search algorithm is a special case of the brute force search.


What are advantage of linear searching?

There no advantages to linear search other than searching for the first (or last) nodes. Linear search takes linear time with an average O(n/2) for each search.


What is the running time of a linear search of an array?

Running time of a linear search is O(n)


Complexity of linear search?

the compexity of linear search in worst case is f(n) = n+1


What is search algorithm?

The linear search algorithm is a special case of the brute force search.


What are the various applications of linear search in real time?

Linear search is necessary when we must search unordered sets. Linear search times across huge sets can be improved significantly by dividing the set amongst two or more threads that can execute on independent CPU cores.


Difference between macor flowchart and micro flowchart?

1. Macro flowchart shows less information whereas micro flowchart shows more information. 2. Macro flowchart is easy to design as comparative to micro flowchart. 3. Macro flowchart is difficult to study and understand as comparative to micro flowchart.


What is the simplest search technique to use to find an item in an array?

Linear search


What are advantages and disadvantages of linear search?

1)in linear search it needs more space and time complexity. 2) in linear search if the key element is the last element and the search is from first element that is a worst case, or if the key element is the first element and the search is from last element then also is the worst case.


What is the basic symbol in flowchart?

there is no basic symbol in flowchart