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]
3 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]3 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
Super easy question but you have to think about it because it’s not that easy I’ll mark brainliest for first answer Explain the
kkurt [141]

Answer:

Databases are not that simple. Now we not only have a Data warehouse, but we also have the Data Lake as well. We also have NoSQL and SQL form of support with these modern databases. The JSON format is rocking. You can hence through JSON store the text, image, audio, video, etc in one go. And like the first five can be a text, the next five can be an image then again a text than video, and so on. And it is super easy to access them as well. Also, you can edit them quite easily as well. It's not that hard like the Lisp used to be in the past. And supermarket has a mix blend of the database. And modern databases like Data Lake can be very useful, undoubtedly.

You can store security type of requirements, like CCTV footage, each shop details like shop ID, Product list, shop type, electricity bill, hours of opening, floor, facilities, no. of employees, etc., and like this, we can have the details for the entire supermarket, and each shop there definitely. And we can perform various actions on behalf of each shop and market as well. The database can hence be very useful definitely

Explanation:

Please check the answer.

8 0
3 years ago
How do i unblock a website on a school computer if a school blocks it?
tresset_1 [31]

Answer:

look up ultrasurf and just follow the thingy and it will download a vpn ive had it on my computer for a fat min

Explanation:

4 0
2 years ago
What is computer system ?​
Over [174]

Answer:

a system that is a computer

6 0
3 years ago
Read 2 more answers
In Python which is the correct method to load a module math?
Wittaler [7]

Answer: The math module is a standard module in Python and is always available. To use mathematical functions under this module, you have to import the module using import math .

Explanation:

3 0
2 years ago
What is intellectual property?
xz_007 [3.2K]

Answer:

The 3rd one

Explanation:

Intellectual property refers to creations of the mind: inventions; literary and artistic works; and symbols, names and images used in commerce. Intellectual property is divided into two categories: Industrial Property includes patents for inventions, trademarks, industrial designs and geographical indications.

7 0
3 years ago
Other questions:
  • Write code statements to create a DecimalFormat object that will round a formatted value to four decimal places. Then write a st
    15·1 answer
  • To make IPv4 addresses a little easier for human beings to understand, the 32-bit binary addresses are represented by dotted dec
    9·1 answer
  • Match the elements of a web page with their descriptions?
    15·2 answers
  • What is your favourite video game??​
    5·2 answers
  • True or False
    11·1 answer
  • What can help an interface user understand or navigate an online interface?​
    15·1 answer
  • Do u have all the subjects​
    12·2 answers
  • A good CRM should Integrate marketing, sales, and customer support activities measuring and evaluating the process of knowledge
    13·1 answer
  • How did the use of ARPANET change computing?
    14·1 answer
  • Microsoft Access is a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!