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


Please Help Members By Posting Answers For Below Questions

How can you pass an array to a function by value?

602


why do some people write if(0 == x) instead of if(x == 0)?

654


Why we not create function inside function.

1750


What is the use of a ‘’ character?

586


What is a keyword?

747






What is difference between && and & in c?

599


What is graph in c?

584


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3341


How do you use a 'Local Block'?

724


Explain spaghetti programming?

684


What does d mean?

586


Explain what is meant by 'bit masking'?

644


Write a code on reverse string and its complexity.

608


write a program to display all prime numbers

1456


Explain what does the function toupper() do?

636