Question: For this task, you are to implement a simple compression algorithm. The logic for this particular simple compression algorithm is shown in the flowchart below:
For this task, you are to implement a simple compression algorithm.
The logic for this particular simple compression algorithm is shown in the flowchart below:
Start
Get input text from the user
Let 'compressed' be an empty string
and start the count at
Let 'prevchar' be the first character
from the input text
Update 'prevchar' to "char'
Add the count and 'prevchar' to the
end of 'compressed'
Display 'compressed'
The purpose of the algorithm is to represent text in a way that is more efficient for many repeated characters. See the examples for how this is expected to work.
Examples for testing
Use the examples below, as well as your own examples, to test your code. The output from your code should exactly match what is shown here.
Example run
Text to compress: aaaabba
aba
Example run
Text to compress: freeeeeeeee
fre
Example run
Text to compress: python
python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
