Searching in C Language
Searching in C Language has to check for an element or retrieve an element from any data structure where the data is stored. Based on the type of search operation, there are generally two algorithms defined in C:
- Linear Search or Sequential Search
- Binary Search
Linear Search or Sequential Search in C Language to find whether a value is exist in a given array. If it is exist then return the current position. In this algorithm we check the value one by one in given list. The time complexity of above algorithm is O(n). It takes more time than Binary Search.
Binary Search in C Language we search in the given sorted elements. In this algorithm we divide sorted elements from middle and check the lie between which part. Same process we try until the all element not read. The time complexity of Binary Search is O(Log n).c language tutorial learn c language study c language