Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will get a set of numbers from the users. In this assignment you should implement a code that calculates the result for Compression Method.CM

You will get a set of numbers from the users. In this assignment you should implement a code that calculates the result for Compression Method.CM has three inputs: number of integers (n), compression level (level), n different integer values. It gives a set of integers which shows the compressed value. CM is calculated as follow:

A = e1, e2, , en CM1(A) = (e1+e2), (e2+e3), , (en-1+en)

For example: When, n = 7, level = 1, and numbers are {1, 2, 3, 4, 5, 6, 7}then the result becomes {3, 5, 7, 9, 11, 13} because of {1+2, 2+3, 3+4, 4+5, 5+6, 6+7}

For the same input, when level = 2, the answer will be {8, 12, 16, 20, 24}

Input Format

Two integer values n, and level, respectively. The next line includes n numbers.

Constraints

The numbers are in integer size

Output Format

A single line that includes a set of numbers

Sample Input 0

7 2 1 2 3 4 5 6 7 

Sample Output 0

8 12 16 20 24 

Explanation 0

Original : 1 2 3 4 5 6 7 Level 1 : 3 5 7 9 11 13 Level 2 : 8 12 16 20 24

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

More Books

Students also viewed these Databases questions

Question

8 Halogens tend to form anions because >

Answered: 1 week ago

Question

Why is the return statement is required in a function body?

Answered: 1 week ago

Question

1. What might have led to the misinformation?

Answered: 1 week ago

Question

2. How will you handle the situation?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago