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
vredina [299]
3 years ago
6

Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter.

Computers and Technology
1 answer:
Artyom0805 [142]3 years ago
3 0

Answer:

Explanation:

The function was written in Java. It takes in an int array returns the same array but with the first and last elements swapped. A test array was used in the image below to demonstrate the output which can be seen in the bottom of the image in red.

   public static int[] SwapArrayEnds(int[] myArr) {

       int temp = myArr[myArr.length-1];

       myArr[myArr.length-1] = myArr[0];

       myArr[0] = temp;

       return myArr;

   }

You might be interested in
A computer retail store has 15 personal computers in stock. A buyer wants to purchase 3 of them. Unknown to either the retail st
Dima020 [189]

Answer:

a. 1365 ways

b. Probability = 0.4096

c. Probability = 0.5904

Explanation:

Given

PCs = 15

Purchase = 3

Solving (a): Ways to select 4 computers out of 15, we make use of Combination formula as follows;

^nC_r = \frac{n!}{(n-r)!r!}

Where n = 15\ and\ r = 4

^{15}C_4 = \frac{15!}{(15-4)!4!}

^{15}C_4 = \frac{15!}{11!4!}

^{15}C_4 = \frac{15 * 14 * 13 * 12 * 11!}{11! * 4 * 3 * 2 * 1}

^{15}C_4 = \frac{15 * 14 * 13 * 12}{4 * 3 * 2 * 1}

^{15}C_4 = \frac{32760}{24}

^{15}C_4 = 1365

<em>Hence, there are 1365 ways </em>

Solving (b): The probability that exactly 1 will be defective (from the selected 4)

First, we calculate the probability of a PC being defective (p) and probability of a PC not being defective (q)

<em>From the given parameters; 3 out of 15 is detective;</em>

So;

p = 3/15

p = 0.2

q = 1 - p

q = 1 - 0.2

q = 0.8

Solving further using binomial;

(p + q)^n = p^n + ^nC_1p^{n-1}q + ^nC_2p^{n-2}q^2 + .....+q^n

Where n = 4

For the probability that exactly 1 out of 4 will be defective, we make use of

Probability =  ^nC_3pq^3

Substitute 4 for n, 0.2 for p and 0.8 for q

Probability =  ^4C_3 * 0.2 * 0.8^3

Probability =  \frac{4!}{3!1!} * 0.2 * 0.8^3

Probability = 4 * 0.2 * 0.8^3

Probability = 0.4096

Solving (c): Probability that at least one is defective;

In probability, opposite probability sums to 1;

Hence;

<em>Probability that at least one is defective + Probability that at none is defective = 1</em>

Probability that none is defective is calculated as thus;

Probability =  q^n

Substitute 4 for n and 0.8 for q

Probability =  0.8^4

Probability = 0.4096

Substitute 0.4096 for Probability that at none is defective

Probability that at least one is defective + 0.4096= 1

Collect Like Terms

Probability = 1 - 0.4096

Probability = 0.5904

8 0
3 years ago
Select the correct answer from each drop-down menu.
evablogger [386]
Update and measure those are the only understand answers
6 0
3 years ago
Read 2 more answers
With the exception of a(n) ____________________, the Paste command allows you to paste an object without creating a link.
mylen [45]
<span>Chart
</span>With the exception of a Chart, the Paste command allows you to paste an object without creating a link.
4 0
3 years ago
What are the main approaches for dealing with deadlock?
alina1380 [7]

Answer:

Deadlock ignorance

Deadlock prevention

Deadlock avoidance

& Detection and recovery

Hope This Helps!!!

3 0
3 years ago
Which html tag designates links to other web pages?.
Tcecarenko [31]

Answer:

<a href>

Explanation:

I found the answer on a Quizlet.

I hope this helps!

3 0
2 years ago
Other questions:
  • What is the software called that allows the user to create, access, and manage a database? question 8 options:
    10·1 answer
  • Multiple users report that the network printer, which is connected through the print server, is not printing. Which of the follo
    12·1 answer
  • ZeroIt is a function that takes one argument and returns no value. The argument is a pointer to int. The function stores the val
    15·1 answer
  • Which of the following techniques would a Baroque composer most likely employ to evoke an affect of agitation? Select one:
    14·1 answer
  • Client/server awareness. Visit three local stores in your neighborhood or mall and notice the information technology in the stor
    9·2 answers
  • The following is an example of what kind of loop?
    15·2 answers
  • What type of ransomware was developed to block the user from accessing the computer and encrypts all the files on the user's dev
    5·2 answers
  • Visit the quick access toolbar to find help when looking for certain commands. True False
    15·2 answers
  • How would you describe<br> "analogous color harmony" to a six year old?
    13·1 answer
  • How do you change your name on your brainly profile
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!