Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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