Skip to content

BoFromTheEast/Archived_message

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived Message Reconstruction

Purpose

The objective of this project is to reconstruct/unzip a message archived with a binary-tree- based algorithm. The program would ask for a single filename at the start: "Please enter filename to decode: ", decode the message in the file and print it out to the console. The name of the compressed message file will end in .arch, e.g. “monalisa.arch”. The file consists of two or three lines: the first one or two lines contain the encoding scheme, and the second or third line contains the archived message.

Encoding

The archival algorithm uses a binary tree. The edges of the tree represent bits, and the leaf nodes contain one character each. Internal nodes are empty. An edge to a left child always represents a 0, and an edge to a right child always represents a 1. The sequence of bits encodes characters along a path from the root to a particular leaf.
Screenshot 2024-03-24 034024

Examples

Prev:
Screenshot 2024-03-24 041630

After:
Screenshot 2024-03-24 041552

Input Format

The archive file consists of two lines: the first line contains the encoding scheme, and the second line contains the compressed string. For ease of development and to make the archive file human-readable, each bit is represented as the character ‘0’ or ‘1’, rather than as an actual bit from a binary file. The encoding scheme can be represented as a string. For example, the tree from section 2 can be represented as: ^a^^!^dc^rb where ^ indicates an internal node. The above code represents a preorder traversal of the tree. The cadbard! message is encoded in the following file (“cadbard.arch”): ^a^^!^dc^rb 10110101011101101010100

About

Archived Message Reconstruction:

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages