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
Answer Posted / 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 |
Post New Answer View All Answers
Explain what is the difference between null and nul?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
How to Throw some light on the splay trees?
Why #include is used in c language?
What are header files? What are their uses?
What is .obj file in c?
Compare array data type to pointer data type
Explain b+ tree?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
What is the basic structure of c?
What does stand for?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
What is a pointer in c?
Why should I prototype a function?
Create a simple code fragment that will swap the values of two variables num1 and num2.