473,383 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Mergesort and couting the amount of inversions

Today, I've programmed Mergesort. And it works very good :-)!

But now, the teacher said that you could use Mergesort to count the amount
of inversions.

This is what I found on the internet:

---
Note: Merge Sort can be slightly modified to count inversion index (i.e.
bubble sort swaps) in O(n log n) time. When the right partition goes in
first in Merge step, that means all the remaining items in left partition <
first element in right partition (i.e. you have to swap with all of them).
---

Can someboy give me some information about that sentence? I don't really
understand the meaning of it...
Oct 30 '05 #1
1 3618
Jochus wrote:
Today, I've programmed Mergesort. And it works very good :-)!

But now, the teacher said that you could use Mergesort to count the amount
of inversions.

This is what I found on the internet:

---
Note: Merge Sort can be slightly modified to count inversion index (i.e.
bubble sort swaps) in O(n log n) time. When the right partition goes in
first in Merge step, that means all the remaining items in left partition <
first element in right partition (i.e. you have to swap with all of them).
---

Can someboy give me some information about that sentence? I don't really
understand the meaning of it...


This is not a question for comp.lang.c++ which deals with standard C++
language issues ONLY. Please find a newgrsoup dedicated to algorithms.

See http://www.parashift.com/c++-faq-lite/ for more information.

--John Ratliff
Oct 30 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
6
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
1
by: ben81 | last post by:
Hi, the following code is adopted PseudoCode from Introduction to Algorithms (Cormen et al). For some reason it can't get it to work. I always get a index of out bounds exception or some weird...
2
by: rkk | last post by:
Hi, My mergesort program is below. There is a small piece of logical error/bug in this code which I can't figure out, as a result the output array isn't completely sorted. Requesting your help...
3
by: xandra | last post by:
hello: how many inversions there in S O T R M E ? thank you
1
by: xandra | last post by:
how many inversions there in S O R T M E? thank you
51
by: Joerg Schoen | last post by:
Hi folks! Everyone knows how to sort arrays (e. g. quicksort, heapsort etc.) For linked lists, mergesort is the typical choice. While I was looking for a optimized implementation of mergesort...
5
by: Chad | last post by:
I was looking at some old posts in comp.lang.c and found the following ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.