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
12) The school that Danielle goes to is selling tickets to a choral performance. On the first day of
kicyunya [14]

Answer:

Senior citizen tickets = $9

Student tickets = $11

Step-by-step explanation:

We begin by converting these into simultaneous linear equation;

Senior citizen tickets = a

Student tickets = b

5a + 9b = 144

14a + 6b = 192

5a = 144 - 9b

a = 144/5 - 9b/5

a = 28.8 - 1.8b

We now substitute this into the first equation

14(28.8 - 1.8b) + 6b = 192

403.2 - 25.2b +6b = 192

-19.2b = 192 - 403.2

b = -211.2/-19.2

b = 11

Put the value of b into either equation

5a + 9b = 144

5a + 9(11) = 144

5a +99 = 144

5a = 144-99

5a = 45

a = 9

6 0
3 years ago
Please answer Quick
Anastaziya [24]
Right angle because that has 90 degree angle
7 0
3 years ago
Read 2 more answers
I need help ASAP pls
Molodets [167]

Answer

Rise from the blue dot run to the red dot. Rise over run.

Step-by-step explanation:

1/8 would be your answer

8 0
3 years ago
Read 2 more answers
What does the word profitable mean
Margarita [4]
Financial gain,beneficial, or useful
3 0
3 years ago
Read 2 more answers
1350 to the nearest 100
nydimaria [60]

Answer:

1350 to the nearest 100 is 1400

3 0
3 years ago
Other questions:
  • Previous
    7·1 answer
  • Use the substitution method to solve the following system of equations:
    11·2 answers
  • Lynn has 10 more pencils than Carol. Let p represent the number of pencils Carol has. Which expression shows how many pencils Ly
    15·2 answers
  • based on the given information which theorem could be used to prove that angle PQR is greater than or equal to angle TSR? QR is
    12·1 answer
  • What is the solution to the system of equations <br> x = y + 4<br> 2x - 3y = -2
    7·1 answer
  • A paint company claims their paint will be completely dry within 45 minutes after application. Recently, customers have complain
    10·1 answer
  • Zoe is using the figure shown below to prove Pythagorean Theorem using triangle similarity.
    12·2 answers
  • Pls help extra points and mark brainlis
    12·1 answer
  • A supervisor records the repair cost for 17 randomly selected stereos. A sample mean of $66.34 and standard deviation of $15.22
    8·1 answer
  • Which of the following statements correctly illustrate the addition property of equality?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!