Urgent Help

Question : minimum number of operation required to sort array.
Operation : Take any element from array and put it to the end .
Please anyone help
https://en.wikipedia.org/wiki/Sorting_algorithm
Review this and figure out which one matches your requirements.
It depends.

The question is incomplete because HOW you pick the element to move is not given, and that is KEY to how many operations it will take. How you put it at the end matters too: do you swap it, or scoot it? Is this worst case, best case, average case?
Last edited on
The minimum number is zero. This occurs when the input array is already sorted.

I expect that isn't the answer you're looking for. Do you mean the minimum for a specific input array? Or the expected number for an algorithm that minimizes the number of operations? Or something else?

If this is homework, can you post the text of the question that you're trying to answer?
The minimum number is probably not zero because you can't know in 0 operation if your array is sorted or not.

It's probably something like N for the sorted (minimum) case.

This complexity can be up to N² (it seems that the sort algo here is some kind of bubble sort).
The minimum number is probably not zero because you can't know in 0 operation if your array is sorted or not.

What is an "operation"?

A call to comparison function? comp( a, b )
A swap/scoot/move?

std::sort claims:
Performs approximately N*log2(N) comparisons of elements, and up to that many element swaps (or moves).
Zaap wrote:
The minimum number is probably not zero because you can't know in 0 operation if your array is sorted or not.
keskiverto wrote:
What is an "operation"?


The OP is specific about this:
Operation : Take any element from array and put it to the end .


So I stand by my statement that the minimum number of "operations" is zero.
Topic archived. No new replies allowed.