Question
The python script (check_prefix_codes.py) will read a sequence of codewords from a file and validate if the code is a prefix code. The file codes.txt
The python script ("check_prefix_codes.py") will read a sequence of codewords from a file and validate if the code is a prefix code. The file "codes.txt" is an example input file.
Write a new script that will read two files
- A file containing the codewords (like codes.txt)
- A file containing the sequence of 1s and 0s representing a compressed file, compressed using the code read from the file.
Your script should first validate if the read code is a prefix code, and then use these codewords to decode the second file. (You can assign arbitrary symbols to each codeword).
Put your results and example inputs and outputs in a .pdf file, and submit your scripts along with the example input file(s) used.
codes.txt:
00
01
10
110
111
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started