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
Keith_Richards [23]
3 years ago
9

Array processing (elimination of three largest values) (one of many array reduction problems) The array a(1..n) contains arbitra

ry integers. Write a function reduce(a,n) that reduces the array a(1..n) by eliminating from it all values that are equal to three largest different integers. For example, if a=(9,1,1,6,7,1,2,3,3,5,6,6,6,6,7,9) then three largest different integers are 6,7,9 and after reduction the reduced array will be a=(1,1,1,2,3,3,5), n=7. The solution should have the time complexity O(n).
Mathematics
1 answer:
ziro4ka [17]3 years ago
8 0

Step-by-step explanation:

# include <bits/stdc++.h>

using namespace std;

bool find3Numbers(int A[], int arr_size, int sum)

{

int l, r;

sort(A, A+arr_size);

for (int i=0; i<arr_size-2; i++)

{

l = i + 1;

r = arr_size-1;

while (l < r)

{

if( A[i] + A[l] + A[r] == sum)

{

printf("Triplet is %d, %d, %d", A[i],

A[l], A[r]);

return true;

}

else if (A[i] + A[l] + A[r] < sum)

l++;

else // A[i] + A[l] + A[r] > sum

r--;

}

}

return false;

}

int main()

{

int A[] = {1, 4, 3, 2, 10, 8};

int sum = 22;

int arr_size = sizeof(A)/sizeof(A[0]);

find3Numbers(A, arr_size, sum);

return 0;

}

You might be interested in
dan spent half of his allowance going to the movies he washed the family car and earn $10 what is his weekly allowance if you en
Angelina_Jolie [31]
12 to 14 is his weekly allowance
7 0
3 years ago
Please help me with this
lawyer [7]

Answer:

14/18 =0.7778

Step-by-step explanation:

14/18 =0.7777.........=0.7778 rounded to the nearest thousandth

7 0
3 years ago
Solving quadratic equations using the quadratic formula.
mixer [17]

Answer:

what is there supposed to be a picture

8 0
2 years ago
HELP ASAP PLEASE WILL MARK BRAINIEST
allsm [11]
It has to be 45 degrees pal
6 0
3 years ago
Find the volume of a sphere with radius 2 feet. Round your answer to the nearest hundredth.
Dmitry_Shevchenko [17]

Answer:

V=33.51ft^3

Step-by-step explanation:

Remember the formula:

V=\frac{4}{3} \pi r^3

V= Volume r= radius

V=\frac{4}{3} \pi 2^3= 33.51032

Round your answer to the nearest hundredth.

V=33.51ft^3

4 0
3 years ago
Other questions:
  • Brainliest for correct answer!
    9·2 answers
  • Tourists covered 640 km for a 4 hour ride by car and a 7 hour ride by train. What is the speed of the train, if it is 5 km/h gre
    6·2 answers
  • 88 less than 8 times a number is 34 less than twice. turn to equation
    13·1 answer
  • The difference between two numbers is 9. The first number plus twice the other number is 27.Find the two numbers.
    9·1 answer
  • Does anyone know what 4n-9=-9 is?? Its a two step equation problem with integers can someone please tell me the answer!?!?!?
    12·2 answers
  • The circumference of a circle is 18 pi feet. What is the area in terms of pi?
    11·1 answer
  • The length of a picture frame is 8 inches more than the width. For what
    15·2 answers
  • Consider the arithmetic sequence with a first term of 11 and sixth term of 21. What is the
    9·1 answer
  • A binomial probability experiment is conducted with the given parameters. Compute the probability of x successes in the n indepe
    15·1 answer
  • H(1)=-35<br><br>h(n)=h(n-1)*2<br><br>h(3)=
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!