Tuesday 22 October 2013

Sorting

Sorting refers to the operation of arranging data in some order such as increasing or decreasing with numerical data or alphabetically with character data

Complexity of Sorting Algorithm

The complexity of a sorting algorithm measures the running time as a function of the number on n of items to be sorted .


Each sorting algorithm S will be made up of the following operations, where A1, A2 , ……, An  contain the items to be sorted and B is an auxiliary location:
(a) Comparisons : which test whether Ai < Aj  or test Ai < B
(b) Interchange, which switch the content of Ai and  Aj  or of Ai  and B
(c) Assignments, which set B := Ai  and then set Aj  := B or Set Aj   := Ai





 Algorithms are divided into two categories:

    Internal Sorts
  and
    External sorts


Internal Sort:

Any sort algorithm which uses main memory exclusively during the sort.

This assumes high-speed random access to all memory.

External Sort:

Any sort algorithm which uses external memory, such as tape or disk, during the sort.


Note: 

Algorithms may read the initial values from magnetic tape or write sorted values to disk, but this is not using external memory during the sort. Note that even though virtual memory may mask the use of disk, sorting sets of data much larger than main memory may be much faster using an explicit external sort. 

Sort Stable


A sort algorithm is said to be “stable” if multiple items which compare as equal will stay in the same order they were in after a sort.


Type of sorting : (internal sorting ) :

(click link to see algoritham to use ) 


1 comment:

  1. Excellent Work, This is a good and Informative post. In this post I truly got quality information.

    ReplyDelete

THANKS FOR UR GREAT COMMENT

Blogger Widgets