Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Run length encoding is one way to compress a sequence with lots of repeated entries. In run length encoding, repeated entries in a sequence are

image text in transcribed
Run length encoding is one way to compress a sequence with lots of repeated entries. In run length encoding, repeated entries in a sequence are replaced by a counter of how many times the repeated. For example, the sequence 1111222 46666611 gets encoded in the following manner 1111222 4 66666 11 14 23 41 65 12 4 times 3 times 1 time 5 times 2 times into the sequence 1423 416512, where the encoded sequence consists of pairs in the form entry counts entry counts entry counts, and so on. Notice that the encoded sequence is shorter than the original sequence as long as there are many repeated entries. Write a program that prompts the user to enter a sequence of integers, separated by a space between each integer, and display the run length encoded output. If the user enters an empty sequence, do not output anything. You may assume that the entered sequence is valid (ie, in the correct format) and contains only integers. Submit your source code in a file named RunLength Encoding.java! Sample input and output (inputs preceded by ): Enter a sequence of integers separated by spaces: > 1111 2 2 2 4 6 6 6 6 6 11 Run length encoder output: 1 4 2 3 4 1 6 5 1 2 Enter a sequence of integers separated by spaces: > 3 3 -5 -5 -5 -5 2 4 4 4 Run length encoder output: 3 2 -5 4 2 1 4 3 2 1 Additional practice problems from the textbook: 5.1, 5.7, 5.10, 5.14,5.19.5.23, 5.26, 3.46 (this is a common interview question!)

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_2

Step: 3

blur-text-image_3

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 Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions