Thursday, May 3, 2012

Sorting and Searching Techniques!!!

In Computer Science, Sorting and Searching are the two basic operations which we will come across frequently. There are many algorithms are available to do Sorting and Searching depending on time complexity and space complexity.

Sorting: Sorting is a technique to arrange the elements in  a proper order like ascending or descending order.
There are many sorting techniques available which are used depending on the no. of elements to sort. Generally time complexity of the sorting technique is Big O of n^2 or O(n^2) where n is the no. elements in the array.

  • Bubble Sort
  • Insertion Sort
  • Selection Sort
  • Quick Sort
  • Merge Sort
  • Heap Sort


Searching: Searching is a technique to find the element from a group of elements. There are many techniques to Search the element in a group of element depending on the efficiency. generally time complexity of the searching technique is Big O of n or O(n) where n is the no.of elements in an array.


Time Complexity: Time complexity for the Sorting and searching is measured in Big O notation. This will represents efficiency of the techniue. It will be measures in three ways namely Best, average and worst cases.
Generally Best , average and worst cases for Sorting are same and it is O(n^2). But They may vary depending on the sorting technique we used. For example for Quick Sort worst case is O(n^2) where as best and average time complexit is O(n*log n).

Comparison of Sorting techniques:

Comparison of sorting techniques

For Searching Best case will be O(1) and worst case and average case will be O(n). similar to Sorting, searching time complexity also varies depending on the technique. For example for Binary search best case will be O(1) where as average and worst case will be O(log n).

Comparison of Searching techniques:
Comparison of searching techniques

No comments:

Popular Posts