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
Tems11 [23]
4 years ago
5

Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar

ray b of length n.
For each i from 0 to n - 1, b[i] = a[i - 1] + a[i] + a[i + 1].
If some element in the sum a[i - 1] + a[i] + a[i + 1] does not exist, it should be set to 0. For example, b[0] should be equal to 0 + a[0] + a[1].
Computers and Technology
1 answer:
Elenna [48]4 years ago
3 0

Answer: provided in the explanation section

Explanation:

import java.util.*;

class Mutation {

public static int[] mutateTheArray(int n , int[] a)

{

int []b = new int[n];

for(int i=0;i<n;i++)

{

b[i]=0;

if(((i-1)>=0)&&((i-1)<n))

b[i]+=a[i-1];

if(((i)>=0)&&((i)<n))

b[i]+=a[i];

if(((i+1)>=0)&&((i+1)<n))

b[i]+=a[i+1];

}

return b;

}

  public static void main (String[] args) {

      Scanner sc = new Scanner(System.in);

      int n= sc.nextInt();

      int []a = new int [n];

     

      for(int i=0;i<n;i++)

      a[i]=sc.nextInt();

     

      int []b = mutateTheArray(n,a);

for(int i=0;i<n;i++)

      System.out.print(b[i]+" ");

     

 

     

  }

}

cheers i hope this helped !!

You might be interested in
Employing the use of a(n) <br> will help you manage a STEM project.
LiRa [457]

Answer:

technicians

Explanation:

the answer is technicians. in my freshmen year we made flash cards and i still have them so i remember it.

7 0
3 years ago
Hello can you please help with this if you want to thank you!
nikklg [1K]

Answer:

hardware and software is the answer

8 0
3 years ago
Read 2 more answers
13. In cell A17, use the SUMIF function to display the total membership in 2023 for groups with at least 40 members
expeople1 [14]

Answer:

On cell G16, type the formula "=SUMIF(G2:G11, ">=40")".

Explanation:

Formulas in Microsoft Excel are used to generate results or values to a cell. The formula must start with an equal sign. The formula above has the function "SUMIF" which is used to provide a sum of numeric values based on a condition.

6 0
3 years ago
The only type of donation you can make to a not for profit is to donate money
amm1812
The correct answer is true
5 0
3 years ago
Read 2 more answers
What are the information ethics associated with IP
Naily [24]

Answer:

The IP stands for intellectual property. And the information ethics related to the IP are the transaction privacy, piracy and the privacy for the ease and giveaways, investigation, namelessness. The trade details must be kept private, and not disclosed to anybody, and the piracy is never allowed. Also, the privacy of all sorts must be ensured for ease and giveaways, surveillance, and confidentiality.

Explanation:

Please check the answer section.

3 0
4 years ago
Other questions:
  • A four year old laptop will not boot and presents error messages on the screen
    8·1 answer
  • Invalid length parameter passed to the LEFT or SUBSTRING function (below)".
    6·1 answer
  • True or False
    13·1 answer
  • Harmful programs used to disrupt computer operation, gather sensitive information, or gain unauthorized access to computer syste
    7·1 answer
  • A jeweler designing a pin has decided to use five stones chosen from diamonds, rubies, and emeralds. In how many ways can the st
    9·1 answer
  • Int [] val = { 3, 10, 44 };
    13·1 answer
  • Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
    8·1 answer
  • If you can name this you get 15 points: ↑↑↓↓←→←→βα
    10·1 answer
  • MODERATOR DELETE MY ACC
    8·2 answers
  • You must configure a certificate authority on your network to use EFS. True or False?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!