Purchase Solution

sorting an array of integers in linear time

Not what you're looking for?

Ask Custom Question

How can I sort an array of integers in O(n) time, where different integers may have different numbers of digits, but the total number of digits over ALL the integers in the array is n?

My assumption is that radix sort is somehow involved.

Purchase this Solution

Solution Summary

This job targets sorting an array of integers in linear time.

Solution Preview

The result is also in the attached file, which is of the same content as the follows:

Let us use the following example to facilitate the explanation:

329
457
1086
8791
1978
2006
12469
12
518
9
178902
985730
234567
985
8943

In this example, the number of digits is 56, i.e., n = 56
Let m be the number of numbers, i.e., m = 15 in this example, then m < n

Let n1, n2, ... nk are the possible number of digits of each number in the array, so in this example,
n1 = 1, n2=2, n3 = 3, n4 = 4, n5 = 5, n6 = 6, ...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic Networking Questions

This quiz consists of some basic networking questions.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.