file_sorting/README.md

1 KiB

External Merge Sort (Big Buffer Strategy)

A C++20 implementation of an external sorting algorithm designed to sort files that are too large to fit into the system's RAM. This project uses a Big Buffer approach to minimize disk I/O by maximizing the use of available memory during both the initial run creation and the merging phases.

Requirements

Clang++ or G++ (Support for C++20 required) Make

Compilation

make

Usage

The binary is located in the build/ directory after compilation.

Generate Data

To generate a test file with 100,000 random records:

./build/main -g 100000 -o input.dat

Sort Data

To sort the generated file using 11 buffers of 10 records each:

./build/main -i input.dat -o output.dat -n 11 -b 10

Options

Flag Description -i Input file path -o Output file path -n Number of buffers (minimum 3) -b Size of each buffer (number of records) -g Generate count random records -e Evaluate and print the contents of a file -d Temporary directory for merge runs