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 the output of the program?? #include<stdio.h> main ( ) { int a=010,sum=0,tracker: for(tracker=0;tracker<=a;tracker++) sum+=tracker; printf(ā %d\nā,sum); } what is the difference between a=10 and a=010??
Which weighs more, a gram of feathers or a gram of gold?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
What are pointers? What are stacks and queues?
what is computer
Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE;
write a program in 'c' to find the value of p[i+1]^n.p,i,n are arguments of a macro and n is a integer
SRUCTURE PROGRAMMING
main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }
What is an identifier?
what are the languages used in c#?
What is the output of following program ? int main() { int x = 5; printf("%d %d %d\n", x, x << 2, x >> 2); }