Question: you are going to write a program to implement the key word encoding algorithm for text compression and decompression. First, scan the file basketball.txt and
you are going to write a program to implement the key word encoding algorithm for text compression and decompression. First, scan the file basketball.txt and replace the four most frequent words by the four special characters: '%', '$', '#', and '*'. Then save the compressed text to another file. In the compressed text, you do not see the most frequent words. Instead, you see the special symbols. Then please write a method to read the compressed file and decompress it to the original text. Note capital letters are converted to lower case during compression. This information cannot be restored during decompression.
Basketball.text is as follows:
Basketball is a team sport in which two teams of five active players each try to score points against one another by throwing a ball through a 10 foot high hoop under organized rules. Basketball is one of the most popular and widely viewed sports in the world.
Points are scored by passing the ball through the basket from above; the team with more points at the end of the game wins. The ball can be advanced on the court by bouncing it dribbling or passing it between teammates. Disruptive physical contact fouls is not permitted and there are restrictions on how the ball can be handled violations.
Through time, basketball has developed to involve common techniques of shooting, passing and dribbling, as well as players' positions, and offensive and defensive structures. While competitive basketball is carefully regulated, numerous variations of basketball have developed for casual play. In some countries, basketball is also a popular spectator sport.
While competitive basketball is primarily an indoor sport, played on a basketball court, less regulated variations have become exceedingly popular as an outdoor sport among both inner city and rural groups.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
