0

An in-place algorithm with O(n) running time that rearranges an unsorted array A[0 . . . n − 1] filled with distinct integers so that, for a given k (1<=k<=n), A[0 . . . k − 1] contains the k smallest integers in increasing order.

Is there an existing algorithm that meets these specifications, or one that can be altered to meet them?

1
  • yes, partially, the homework requires the implementation of this algorithm but the professor said in class that the algorithm already exists, I just need to know which one it is, then I can study it and implement it, can you help? Commented Oct 20, 2010 at 17:13

1 Answer 1

2

If you google for O(n) sorts, you would end up with Counting Sort or Radix Sort.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.