Describe two techniques that you can apply to narrow or broaden a search. Discuss the advantages and disadvantages of each. Which approach will improve the effectiveness of your searches?
Searching is a process to find required information from specific source. Search can be applied using specific algorithms. There are different searching techniques available according to narrow down search time and efficiency. The article would be on two techniques and its effectiveness. Sometimes search is applied to find out element in list. Search techniques can be applied on sorted and unsorted data. In this proposed document we would be discussing two of them
- Linear Search
- Binary Search
Linear search algorithm is used to search element in array list. Linear search is applied on sorted and unsorted data. In this technique searching is done from left to right in array and it runs again and again till element is not found. Therefore it is called sequential search. It is the simplest search technique and in worst case scenario complexity is number of elements in list. Linear search is applied in mostly array type data structure.
The major advantage of this technique is that it can be implemented easily and disadvantage is that it requires large space to run.
Binary search is applied on only sorted data only. This technique is the best approach of searching element and can be applied on any data structure. It works as dividing list into small lists and checks element from left to middle and from middle term to right. Basically whole list is divided into two lists by assigning terms left, middle and right most.
Binary search works in two cases best case and worst case. Best case technique gives O(1) complexity and in worst case scenario is nLog(n). The main advantage of this technique is that it can be applied on any data structure.