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 |
f(x,y,z) { y = y+1; z = z+x; } main() { int a,b; a = 2 b = 2; f(a+b,a,a); print a; } what is the value of 'a' printed
Explain how are portions of a program disabled in demo versions?
Is stack a keyword in c?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
Explain how do you determine whether to use a stream function or a low-level function?
Is it better to bitshift a value than to multiply by 2?
What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }
array contains zeros and ones as elements.we need to bring zeros one side and one other side in single parse. ex:a[]={0,0,1,0,1,1,0,0} o/p={0,0,0,0,0,1,1,1}
Explain what does the function toupper() do?
how to sort two array of characters and make a new array of characters.
When is a void pointer used?
How to write in a function declaration and in function call in which the function has 'n' number of varible or arguments?