Skip to content

Ranking comparison using merge sort and inversion counting

Notifications You must be signed in to change notification settings

landreea03/Ranking-algorithm

Repository files navigation

Ranking Comparison Using Inversion Counting

Overview

This project implements an efficient algorithm to compare multiple ranking lists against a reference ranking using merge sort and inversion counting. It measures how similar each ranking source is to the reference by counting how many pairs of elements are out of order.

The project demonstrates:

  • Divide-and-conquer algorithms
  • Efficient inversion counting using merge sort
  • Real-world data processing with large datasets
  • Modular and algorithmic problem solving

Algorithms Used

  • Merge Sort
  • Inversion Counting
  • Divide and Conquer Strategy

Project Structure

Ranking-algorithm/ ├── main.py ├── CS-3364.ipynb ├── source1.txt ├── source2.txt ├── source3.txt ├── source4.txt ├── source5.txt


📥 Input

The program uses five text files, each representing a ranking list from a different source:

  • source1.txt
  • source2.txt
  • source3.txt
  • source4.txt
  • source5.txt

Each file contains a list of ranked items (IDs and optionally scores).


How to Run

1.Check with: python3 --version

2.Install dependency This project uses pandas for pretty table output: python3 -m pip install pandas

3.Run the program From inside the project folder: python3 main.py

Output

The program prints a table with the following columns: Source File Overlap (number of common items with reference) Inversions (number of out-of-order pairs) Max Inversions (maximum possible inversions) Reliability (similarity score between 0 and 1)

Course Context

This project was developed as part of a university algorithms course and demonstrates efficient handling of large datasets (~10,000 elements per file) using O(n log n) algorithms. Course: CS 3364 — Design and Analysis of Algorithms Topic: Divide and Conquer, Inversion Counting, Algorithmic Analysi

About

Ranking comparison using merge sort and inversion counting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published