# CountingSort

• Last Updated : 05 Mar, 2016

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values (kind of hashing). Then doing some arithmetic to calculate the position of each object in the output sequence … More on Counting Sort

 Question 1
Which of the following is not true about comparison based sorting algorithms?
 A The minimum possible time complexity of a comparison based sorting algorithm is O(nLogn) for a random input array B Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared C Counting Sort is not a comparison based sorting algorithm D Heap Sort is not a comparison based sorting algorithm.
Sorting    Analysis of Algorithms    CountingSort    HeapSort    50 Algorithms MCQs with Answers
Discuss it

Question 1 Explanation:
 Question 2
Which sorting algorithms is most efficient to sort string consisting of ASCII characters?
 A Quick sort B Heap sort C Merge sort D Counting sort
Sorting    QuickSort    CountingSort    HeapSort
Discuss it

Question 2 Explanation:
Counting sort algorithm is efficient when range of data to be sorted is fixed. In the above question, the range is from 0 to 255(ASCII range). Counting sort uses an extra constant space proportional to range of data.
 Question 3
Given an array where numbers are in range from 1 to n6, which sorting algorithm can be used to sort these number in linear time?
 A Not possible to sort in linear time B Radix Sort C Counting Sort D Quick Sort
Sorting    QuickSort    RadixSort    CountingSort
Discuss it

Question 3 Explanation:
See Radix Sort for explanation.
There are 3 questions to complete.

## Coding practice for sorting

My Personal Notes arrow_drop_up

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.