Skip to content

Conversation

@Divakar-2508
Copy link
Contributor

Description

This PR adds the Move-To-Front (MTF) Encoding algorithm under the compression category.

Algorithm Overview

Move-To-Front (MTF) Encoding is a lossless data compression algorithm that replaces each character with its position in a dynamically updated list. Every time a character is accessed, it moves to the front of the list. This technique is commonly used as a preprocessing step before further entropy encoding, such as Burrows-Wheeler Transform (BWT).

For more details: [Move-To-Front Transform - Wikipedia](https://en.wikipedia.org/wiki/Move-to-front_transform)

Implementation Details

  • Uses a Vec as a lookup queue for efficient front insertions.
  • Implements both encoding and decoding functions.
  • Includes unit tests to verify correctness.

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I ran the following commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked CONTRIBUTING.md, and my code follows its guidelines.

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.50%. Comparing base (b4aecf4) to head (d3cd07e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #874   +/-   ##
=======================================
  Coverage   95.49%   95.50%           
=======================================
  Files         316      317    +1     
  Lines       22919    22948   +29     
=======================================
+ Hits        21887    21916   +29     
  Misses       1032     1032           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vil02 vil02 merged commit b19c743 into TheAlgorithms:master Mar 20, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants