Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting in linear time? [closed]

Tags:

Given an input set of n integers in the range [0..n^3-1], provide a linear time sorting algorithm.

This is a review for my test on thursday, and I have no idea how to approach this problem.

like image 500
Stefan Kendall Avatar asked Apr 14 '09 22:04

Stefan Kendall


People also ask

Can sorting be done in linear time?

since you have a range of integers, then yes, it can be linear, but this won't always be the case. This is also known as "bucket sort".

Which sorting algorithm runs linear time?

Bucket sort runs in linear time on the average. Like counting sort, bucket sort is fast because it assumes something about the input.

Can we sort an array in linear time?

Sort the given array in linear time. Try It! Solution: If we use Counting Sort, it would take O(n^2) time as the given range is of size n^2. Using any comparison based sorting like Merge Sort, Heap Sort, .. etc would take O(nLogn) time.

What is linear sorting?

Linear sorting: Radix sort. An important property of counting sort is that it is stable, numbers with the same value, appear in the output in the same order as they do in the input. For instance Heap sort is not stable.


1 Answers

Also take a look at related sorts too: pigeonhole sort or counting sort, as well as radix sort as mentioned by Pukku.

like image 107
Ray Hidayat Avatar answered Sep 22 '22 03:09

Ray Hidayat