1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
valentinak56 [21]
3 years ago
14

Assume that someone dictates you a sequence of numbers and you need to write it down. For brevity, he dictates it as follows: fi

rst says the number of consecutive identical numbers and then says the number itself. E.g. The sequence 1 1 3 3 3 2 2 2 2 14 14 14 11 11 11 2 will be dictated as "Two ones, three threes, four twos, three fourteens, three elevens, one two", so you will write down the sequence 2 1 3 3 4 2 3 14 3 11 1 2. The challenge is to write the program which compresses the given sequence using this approach.
Computers and Technology
1 answer:
hram777 [196]3 years ago
4 0

Answer:

Answer is in java language

Explanation:

Java Code

public class Compress{

public static void main(String []args){

      int[] array=new int[]{1 ,1 ,3 ,3, 3, 2, 2, 2, 2, 14, 14, 14, 11, 11, 11, 2};

      int currentNumber=array[0];

      int count=1;

      for(int i=1;i <array.length;i++){

          if(currentNumber != array[i]){

              System.out.print(count+" " +currentNumber+" ");

              currentNumber=array[i];

              count=1;

          } else{

              count++;

          }

      }

      System.out.print(count+" " +currentNumber+" ");

  }

}

Code Explanation

First create two variables which will hold the current number and its count and then iterate over every element in array. If current index value is different from currentNumber variable then display the previous calculated number value and its count and then change the value to current index of array.

At the end display the last calculated value.

Example

Answer will look like below

2 1 3 3 4 2 3 14 3 11 1 2

You might be interested in
If you want to design computing components for cars and medical
Marysya12 [62]

Computer engineering is the course you have to study if you want to design computing components for cars and medical equipment.

<h3>What Is Computer Engineering?</h3>

Computer Engineering is known to be one filed that is made up of the fields of electrical engineering and also that of computer science to form new kind of system hardware or software.

Based on the above, Computer engineering is the course you have to study if you want to design computing components for cars and medical equipment.

Learn more about Computer engineering from

brainly.com/question/24181398

#SPJ1

4 0
3 years ago
It’s important to consider adjusting a user’s social network permissions (or access) because
Liula [17]
<span>You may not want to share access to social networks with other members of your team. Also you may want to adjust your users social permission for security reasons, just to be on the safe side. A stronger network means you have a lower chance of a hacker breaking through your system.</span>
5 0
3 years ago
Original Source Material
Deffense [45]

Answer:

b. Paraphrasing plagiarism

Explanation:

-Word-for-Word plagiarism  refers to copying words from someone else as your own.

b. Paraphrasing plagiarism refers to copying an idea from someone else making small changes without giving credit to the owner.

As the student paraphrased but didn't include the proper reference, this is paraphrasing plagiarism.

5 0
4 years ago
How to fix this.. facing this problem to upload logo
AlekseyPX
I use an app called codechecker that helps with me having issues like that cause 99% of the time I'll mess it up.
7 0
3 years ago
This innovator created “honeypots” in which fake accounts are set-up in order to catch cyber criminals.
statuscvo [17]

Answer: A

Explanation:

3 0
4 years ago
Read 2 more answers
Other questions:
  • A spreadsheet program has many subparts. What is the smallest unit in a spreadsheet?
    9·2 answers
  • I have a class named Counter. In this class I have a synchronized method called countRange(). This method prints out a count in
    10·1 answer
  • Host A is a PC, connected to switch SW1 and assigned to VLAN 1. Which of the following are typically assigned an IP address in t
    13·1 answer
  • In both direct flooding attacks and _____ the use of spoofed source addresses results in response packets being scattered across
    9·1 answer
  • Identify actions to take when establishing a business. Check all of the boxes that apply.
    6·2 answers
  • Software on your computer is taking a long time to load. What could help solve this problem?
    5·1 answer
  • Which of the following components helps to limit the front-to-back movement of the crankshaft? 
    9·2 answers
  • What is professional education? <br><br><br><br><br>Please help me to do this.​
    7·2 answers
  • Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print t
    8·1 answer
  • which type of virtual machine (vm) takes advantage of unused capacity in data centers at a much lower cost than regular vms of s
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!