Sorting and searching are the fundamental operations in computer science. Sorting actually refers to the operation of arranging data in some given order, such as increasing or decreasing, with numerical data, or alphabetically, with character data. While, searching refers to the operation of finding the location of a given item in a collection of items. There are so many sorting and searching algorithms. Some of them such as heap sort and binary search are commonly used.
The specific algorithm one chooses depends on the properties of the data and the operations one may perform on data. Accordingly, complexity of each algorithm can be found out; that is, we want to know the running time f (n) of each algorithm as a function of the number n of input items. Normally the complexity function measures only the number of comparisons, since the number of other operations is at most a constant factor of the number of comparisons.
Sometimes we also discuss the space requirements of our algorithms. Sorting and searching frequently apply to a file of records. There are so many different searching and sorting techniques. All techniques have their own merits and demerits. If one technique is not efficiently working in one situation than it is not necessary that the same technique will never work efficiently in any other situations, might be that works more efficiently than ever in some favourable situation.
The specific algorithm one chooses depends on the properties of the data and the operations one may perform on data. Accordingly, complexity of each algorithm can be found out; that is, we want to know the running time f (n) of each algorithm as a function of the number n of input items. Normally the complexity function measures only the number of comparisons, since the number of other operations is at most a constant factor of the number of comparisons.
Sometimes we also discuss the space requirements of our algorithms. Sorting and searching frequently apply to a file of records. There are so many different searching and sorting techniques. All techniques have their own merits and demerits. If one technique is not efficiently working in one situation than it is not necessary that the same technique will never work efficiently in any other situations, might be that works more efficiently than ever in some favourable situation.