Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***PYTHON*** The program should have a main function to handle the main functionality of the code, the main function is responsible for taking user input

***PYTHON***

image text in transcribed

The program should have a main function to handle the main functionality of the code, the main function is responsible for taking user input and call appropriate encode and decode function and print the user string, encoded string and decoded string. The decoded string is actually be equal to input string, The pseudocode for encode function is provided in this file. The encode function takes the input string as parameter and return the encoded string. Encode function first builds the list of unique prefixes and then the encode list of tuples. Then from the tuple it builds the encoded string The decode function takes the encoded string as parameter and returns the decoded string. The process of decoding is exactly the reverse process of encoding. It takes the encoded string and then builds the encode list of tuples and then from the encode list it gets back the original string o o o o Start of encode function o Initialize a unique prefix list to store all the unique prefixes o Initialize an encode list to store the encoded tuple o Initialize an empty prefix string o Initialize an empty encoded string o Begin processing each character of input string If (prefix string + char) exists in unique prefix list * Add char to prefix string . - Else . . . . Create a tuple which contains the index and the last char Add the tuple to encode list Add (prefix string + char) to unique prefix list Reset the prefix string o Start building encoded string by processing each tuple of the encode list Get the prefix index of the tuple Calculate the total length of the bit to represent the prefix index Get binary value of the prefix index from tuple and strip off 'Ob' " " * Check the length of the binary prefix index and pad with 'O' if necessary Concatenate binary prefix index to encoded string Get integer asci value of the prefix string of each tuple Convert integer value to corresponding binary and strip off 'Ob' Check for the 8-bit length of the binary prefix and pad with '0' if necessary Concatenate binary prefix to encoded string " * o Return encoded string End of encode function o

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago