Which of the following sorts is quickest when sorting the
following set: 1 2 3 5 4
1) Quick Sort
2) Bubble Sort
3) Merge Sort
Answers were Sorted based on User's Feedback
Answer / prof.gagandeep jagdev
Quick Sort, Since the array is already sorted, so this can
be considered as Best case example. The complexity of quick
sort in best case is O(n log n). No doubt , same is the
complexity of Merge sort in best case, but Quick sort
enjoys priority over Merge Sort because Merge sort requires
extra memory( an array) to store the sorted result whereas
quick sort do not specify any such need.
| Is This Answer Correct ? | 10 Yes | 1 No |
Answer / rohith
quick sort is the best sorting algorithm because time
complexity is O(nlogn)
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / sreejesh1987
*I think answer is Bubble sort,because some comparisons are there,but only one swap(4 and 5).
*Best case for for quick sort for this problem applicable to
54321 element set. Here many swaps and comparison will occur.
*Merge sort also does actions of swaps and comparisons.
For most arrays, quick sort and merge sort are better.
But for a simple problem like this, bubble sort consume less operations.
| Is This Answer Correct ? | 1 Yes | 0 No |
what is an array
How to swap 3 numbers without using 4th variable?
in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?
What is the difference b/w Structure & Array?
Why c is called a mid level programming language?
What are nested functions in c?
What is the advantage of c?
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?
What are dangling pointers in c?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
void swap(int a,int b) { a=a+b; b=a-b; a=a-b; } in this code always gives the same result for all case
Why is #define used?