Linear search algorithm (Linear Search)

What is linear search (Linear Search)?

Linear Search is a very basic search algorithm. In this type of search, a continuous search operation takes place through every element. Each element is checked and if any connection is found, that particular element is returned; If not found, the search process continues until the data is searched.

Linear search algorithm (Linear Search) Picture 1

Linear search algorithm

 Gi ả i thu ậ t t ì m ki ế m tuy ế n t í nh ( M ả ng A , Gi á tr ị x ) B ướ c 1 : Thi ế t l ậ p i th à nh 1 B ướ c 2 : N ế u i > n th ì chuy ể n t ớ i b ướ c 7 B ướ c 3 : N ế u A [ i ] = x th ì chuy ể n t ớ i b ướ c 6 B ướ c 4 : Thi ế t l ậ p i th à nh i + 1 B ướ c 5 : T ớ i b ướ c 2 B ướ c 6 : In ph ầ n t ử x đượ c t ì m th ấ y t ạ i ch ỉ m ụ c i v à t ớ i b ướ c 8 B ướ c 7 : In ph ầ n t ử kh ô ng đượ c t ì m th ấ y B ướ c 8 : Tho á t 

Algorithm model for linear search

 B ắ t đầ u h à m linear_search ( list , value ) for m ỗ i ph ầ n t ử trong danh s á ch if match item == value return v ị tr í c ủ a ph ầ n t ử k ế t th ú c if k ế t th ú c for k ế t th ú c h à m 

To find out the full code deployment for Linear Search in C language, please click on chapter: Linear search in C

According to Tutorialspoint

Previous article: Queue data structure (Queue)

Next article: Binary Search algorithm (Binary Search)

5 ★ | 1 Vote

May be interested

  • What is algorithm?What is algorithm?
    algorithms (also known as algorithms - english is algorithms) is a finite set of instructions to be executed in a certain order to get the desired result. in general, the algorithm is independent of programming languages, ie an algorithm can be deployed in many different programming languages.
  • Shell Sort in data structure and algorithmShell Sort in data structure and algorithm
    shell sort is a highly efficient sorting algorithm based on insertion sorting algorithm (insertion sort). this algorithm avoids the case of swapping positions of two distant elements in the selection algorithm (if the smaller element is in the right position quite far from the larger element on the left).
  • How does YouTube algorithm work?How does YouTube algorithm work?
    have you ever wondered how youtube algorithm works?
  • Google changed the search ranking algorithm, limiting the display of fake newsGoogle changed the search ranking algorithm, limiting the display of fake news
    see how google changes the search ranking algorithm, limiting the display of fake news!
  • Google 'prioritizes' sites that use HTTPS protocolGoogle 'prioritizes' sites that use HTTPS protocol
    google is quietly changing some of the algorithms included in the ranking list of sites returned from google search. accordingly, google will favor web sites that use https security protocols.
  • Selection sort algorithm (Selection Sort)Selection sort algorithm (Selection Sort)
    selection sort is a simple algorithm. this sorting algorithm is an algorithm based on in-place comparison, in which the list is divided into two parts, sorted (list) on the left and unsorted (unsorted list) in the right. initially, the sorted part is blank and the unordered part is the original list.
  • Quick Sort (Quick Sort)Quick Sort (Quick Sort)
    quick sort is a highly efficient algorithm and is based on dividing the array into smaller pieces.
  • Build high quality sites to improve search resultsBuild high quality sites to improve search results
    in recent months, google has paid special attention to the issue of helping people find high quality results pages.
  • Google Panda - Algorithm for real rankings?Google Panda - Algorithm for real rankings?
    recently, google has updated an important component of ranking websites that affected 12% of search results and reduced the number of visits for many sites. here's how to find out whether the webstie you have - will be affected and what you should do to deal with it.
  • 3 free tools to keep track of Google update algorithms every day3 free tools to keep track of Google update algorithms every day
    to know when google algorithms are updated, we need to use some tracking tools by analyzing the ranking of tools and search results for thousands of websites and top keywords. here are 3 free tools to help you track changes in google algorithms.