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]
4 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]4 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
Drag the expressions to the boxes to order from least to greatest
skad [1K]

Answer:

3/4x4/9 least

then 7/7x4/9

then 1 2/3x4/9

Greatest is 2x4/9

Step-by-step explanation:

5 0
3 years ago
Solve for x under the assumption that x &gt; 0. Enter your answer in interval notation using grouping symbols.
Delicious77 [7]
<span>Starting with x−24/x<10 multiply everything by x. x^2-24<10x Subtract 10x from both sides. x^2-10x-24 < 0 Factor. (x-12)(x+2) < 0 (x+2) is always positive since x > 0, but (x-12) is negative when x is a value between 0 and 12. This negative value for (x-12) satisfies that the left side is less than 0. Thus the solution set for x is (0,12).</span>
3 0
3 years ago
Use what you know about the angle sum theorem for triangles and your algebra skills to solve for x and find the measure of all t
melomori [17]

Answer:

2x° = 45°, 3x° = 67.5°

Step-by-step explanation:

Sum of angles in a triangle = 180°

2x+3x+3x=180°

8x=180°

x=22.5°

2x=22.5°x2=45°

3x=22.5°x3=67.5°

8 0
3 years ago
Or has an endpoint at (25,-5) and a midpoint of 18,-1) what is the value of the x-coordinate of the other endpoint
Sergio [31]
I believe it's 11

Hope this helped!
4 0
4 years ago
Read 2 more answers
Solve the inequality: y - 18 &lt; 55
Troyanec [42]

Answer:

y < 73

Step-by-step explanation:

y−18+18<55+18

y < 73

7 0
3 years ago
Other questions:
  • 2.891 value of the 1
    14·1 answer
  • If the marginal propensity to consume is 0.8, (a) what is the value of the multiplier?
    8·1 answer
  • If A = 34 degrees, what must be the measure of D in order for ABC to be similar to DEF?
    8·2 answers
  • What is 2/3 ÷ 4/5 = ?
    12·2 answers
  • Can you help me please .<br> Thank you.<br>A) 15.75<br>B)15.9<br>C)31.5
    6·1 answer
  • A cylindrical basin is 2 feet tall and has a diameter of 5 feet, as shown.
    13·2 answers
  • Help me please!!!!!!!
    5·2 answers
  • A cereal box has a length of 8 inches, a width of1 - inches, and a height of 12 - inches. What is thevolume of the cereal box?
    12·2 answers
  • If someone eats 3/4 of granola bars per week, what fraction of a box do they eat in per day ?
    12·1 answer
  • <img src="https://tex.z-dn.net/?f=%20%5Csqrt%7B7%7D%20" id="TexFormula1" title=" \sqrt{7} " alt=" \sqrt{7} " align="absmiddle" c
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!