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
What is the minimum number of data points you should usually have to look for signs of improvement on a run chart?
nexus9112 [7]

Answer:

There Should be at least 10 Points

Explanation:

An execution graph becomes more powerful as you add more data points because there will be more opportunities to identify patterns. If you are looking for signs of improvement, you usually need at least 10 data points.

Performance charts (frequently acknowledged as line graphs outside the excellence management field) display the performance of the process over time

6 0
3 years ago
What is a motherboard​
aleksandr82 [10.1K]

Answer:

A motherboard is the main printed circuit board in general-purpose computers and other expandable systems. It holds and allows communication between many of the crucial electronic components of a system

Explanation:

8 0
3 years ago
What processes can move a solute against its concentration gradient?
Rudiy27

Explanation:

To move substances against a concentration or electrochemical gradient, the cell must utilize energy in the form of ATP during active transport. Primary active transport, which is directly dependent on ATP, moves ions across a membrane and creates a difference in charge across that membrane.

7 0
3 years ago
What specific database stores local user accounts on local computers, and allows users to sign in to and access resources only o
Yuki888 [10]

Answer:

The Security Account Manager

Explanation:

The Security Account Manager (SAM), This is a database file found in Windows Operating Systems.... Windows XP, Windows Vista, Windows 7, 8.1 and 10 that stores users' passwords. It can be used to authenticate local and remote users. It is  an important and vital component of how Windows stores passwords locally on the computer.

5 0
3 years ago
TRUE OR FALSE!!!!!
VladimirAG [237]
The answer is True.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Shawn wants to work on a presentation. He pushes the power buttons for the computer and the monitor, but the computer fails to s
    10·1 answer
  • Henry Ford would have been most interested to bring which modern innovation to his automotive factories?
    5·2 answers
  • A model release can be either oral or written down. true or false
    13·2 answers
  • Tony is in charge of all presentations for a Fortune 500 pharmaceutical company. In addition to creating powerful and persuasive
    9·1 answer
  • What is the autocad term for standard section line symbols?
    13·1 answer
  • A browser is used for creating Web pages. true or false?
    5·2 answers
  • Create a view named Top10PaidInvoices that returns three columns for each vendor: VendorName, LastInvoice (the most recent invoi
    12·1 answer
  • Easy coding question, please help.
    13·1 answer
  • What is the primary purpose of source code editor features such as keyword hi lighting and auto-completion A.to speed up the cod
    7·1 answer
  • A computer is assigned an IP address of 169.254.33.16. What can be said about the computer, based on the assigned address?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!