Mergesort algoritm that sorts numbers in decreasing order?

What will be the mergesort algorithm that sorts numbers in decreasing order?

Same as the one that does in ascending order, just flip the comparison operator.

Best Answer

I'm giving u the program (in C), just go through it, then write the algo. It'll be easier.

// Program : MERGE SORT


void mergesort(int *,int);

void main()
int x[30],n,i;
printf("Enter total no. of elements");
printf("Enter %d nos.",n);
for(i=0;i scanf("%d",&x[i]);


printf("After sorting in descending order :\n");
printf(" %d",x[i]);


void mergesort(int x[],int n)
int aux[30],l1,l2,u1,u2,i,j,k,size;
size=1; // merges file of size 1
while(size {
l1=0; // initialize lower-bound of 1st. file
k=0; // k is index for auxilliary array
while(l1+size {
// initialize remaining parameters...
u2=(l2+size-1) for(i=l1,j=l2;i<=u1 && j<=u2;k++)

} /* end of 2nd. while-loop */
for(i=l1;k aux[k++]=x[i];
for(i=0;i x[i]=aux[i];

} /* end of 1st. while-loop */

30 Related Question Answers Found Date
Microsoft word? 2022-01-19 06:09
Help with html form redirect function - how do you redirect to external site after form submitted? 2022-01-19 06:09
How do i create a Java Library Maintenance System. Any recommended website for me to refer? 2022-01-19 06:04
How do i change the background of my picture using Adobe photoshop? 2022-01-19 06:04
what is RSS( technology) , advantage and disadvantage, funtion or system of RSS? 2022-01-19 05:57
is java programmer is also called java developer?please explain if there is a difference? 2022-01-19 05:38
How do you create a lead capture page by yourself? 2022-01-19 05:33
Can anyone tell me, concisely, the differences between vb, vb6, vbscript, vbnet? 2022-01-19 05:13
What does the suffix .INI in BOOT.INI mean? 2022-01-19 05:12
Is there a free software to to send direct html e-mail? 2022-01-19 04:57
write a program to add two numbers without using arithmetic opereations ( +,-,*,/,%)? 2022-01-19 04:57
Trigger Delete in SQL? 2022-01-19 04:40
???.net it's urgent !? 2022-01-19 04:18
hi frnds, which book is the best for pl sql "brush up" learning with "interview" point of view? 2022-01-19 04:13
can you plz explain me with this? 2022-01-19 04:00
How in C programming,we can assign a float value to a char value? 2022-01-19 03:54
How do I change my windows title bar using dreamweaver? 2022-01-19 03:44
What is the function of 'post slug' when writing a post in WordPress? 2022-01-19 03:43
Question about visual c++? 2022-01-19 03:42
Visual Basic 6 ADO problem? 2022-01-19 03:37
Why do a lot of ERP implementaions fail?javascript:void(0);? 2022-01-19 03:25
hello , plz where i could find a free library"" psd files ""specially landscape images? 2022-01-19 03:24
Where do I get a good tutorial for SAP & ABAP programming online for free? 2022-01-19 03:13
How can I access samba shared folder in the shell(linux)? 2022-01-19 03:13
Any GOOD web page designers you can trust on line? 2022-01-19 03:03
How can I animate my picture? 2022-01-19 02:54
my C programs are compiling with no error in turbo c++ i am not able to see the output???plz help..? 2022-01-19 02:46
phpbb upgrade within php-nuke? 2022-01-19 02:31
how do i get? 2022-01-19 02:23
who composed the theme music you hear when you open windows xp? 2022-01-19 02:21