Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
COUNTING SORT
#1



Abstract

Counting sort is a linear time sorting algorithm used to sort items when they belong to a fixed and finite set. Integers which lie in a fixed interval, say k1 to k2, are examples of such items.
The algorithm proceeds by defining an ordering relation between the items from which the set to be sorted is derived (for a set of integers, this relation is trivial).Let the set to be sorted be called A. Then, an auxiliary array with size equal to the number of items in the superset is defined, say B. For each element in A, say e, the algorithm stores the number of items in A smaller than or equal to e in B(e). If the sorted set is to be stored in an array C, then for each e in A, taken in reverse order, C[B[e]] = e. After each such step, the value of B(e) is decremented.

Counting sort is a stable sort and has a running time of (n+k), where n and k are the lengths of the arrays A (the input array) and C (the counting array), respectively. In order for this algorithm to be efficient, k must not be much larger than n.
The indices of C must run from the minimum to the maximum value in A to be able to index C directly with the values of A. Otherwise, the values of A will need to be translated (shifted), so that the minimum value of A matches the smallest index of C. (Translation by subtracting the minimum value of A from each element to get an index into C therefore gives a counting sort. If a more complex function is used to relate values in A to indices into C, it is a bucket sort.) If the minimum and maximum values of A are not known, an initial pass of the data will be necessary to find these.

Read more:
http://en.wikipediawiki/Counting_sort
http://cse.iitk.acusers/dsrkg/cs210/appl...count.html
http://personal.kent.edu/ rmuhamma/Algorithms/MyAlgorithms/Sorting/countingSort.htm


Reply

#2
hi i am papry from Bangladesh studying B.Sc in computer science and engineering..Now i am in a need of re port based on counting sort algorithm..it should highlight on it's definition,characteristics..
Reply

#3
sorry yaar
i couldn't find a complete report here. why don't you visit the links given? those should have complete details i hope.
Reply

#4

some details on counting sort is in the following thread.

http://seminarsprojects.net/Thread-counting-sort--17062
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.