TOPICS (Click to Navigate)
Monday, 26 February 2018
Linear search program in C using array
int linear (int a, int tot_keys, int k);
int flag=0, found_at;
printf ("\n Enter the number of elements : ");
scanf ("%d", &n);
for(i=0; i<n; i++) //to read list of keys
printf("\n Enter the key %d:", i);
printf("\nEnter the data to be searched for:");
//following line calls the function linear with the parameters array of keys (a), total //keys (n) in the array, and the key (key) to be searched. The result returned by the //function stored in variable ‘found_at’.
found_at = linear(a, n, key);
printf("\nData is present at position %d", found_at);
printf("\nData not present");
int linear(int a, int tot_keys, int k)
int i, position = -1;
for(i=0; i < tot_keys; i++) //this loop executes the number of keys time
if(a[i]==k) //checks if the key at position i is equal to key to be searched
position = i; //we remember the position of key in array
Linear search program in C
Sequential search program in C
SQL Exercises for Beginners / Simple SQL Exercises with Answers / Solved SQL exercises / SQL solved exercises with simple conditions / So...
Advanced concepts in DBMS Advanced Database Topics (Click on the links to navigate) Advanced Concepts in D...
Set of solved exercises in Normalization / Normalization Solved Examples / How to find candidate keys, and primary keys in database? /...
Query Processing in DBMS / Steps involved in Query Processing in DBMS / How is a query gets processed in a Database Management System? / Q...