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
You and a friend are baking cookies. You ask how much water she added to the batter and she says "15" What is wrong with her ans
REY [17]
Nothing is writing with her answer
8 0
3 years ago
Read 2 more answers
Which value is included in the solution set for the inequality graphed one the number line?
Soloha48 [4]

<em>We can also graph inequalities on the number line. The following graph represents the inequality x≤2 . The dark line represents all the numbers that satisfy x≤2 . If we pick any number on the dark line and plug it in for x, the inequality will be true.</em>

6 0
3 years ago
Calculate the mean, median, and mode of the following set of data. Round to the nearest tenth. 3, 15, 3, 3, 1, 11, 2, 8, 3, 7, 1
zubka84 [21]
The mode is 3. The median is 3. The mean is 6.45 and rounded to the nearest tenth is 6.5. So the mean is 6.5.
6 0
3 years ago
What do i write? giving 10 points
n200080 [17]

Answer: get a pencli and put it on the paper a move it aroud

Step-by-step explanation:

6 0
2 years ago
Read 2 more answers
Haizzz, help me pls!!!
n200080 [17]

The correct answer is 5, 3. As x increases by 1, y increases by 1 as well.

Therefore the answer is 5, 3

5 0
3 years ago
Other questions:
  • Using kilograms and grams relate to your understanding of place value
    11·1 answer
  • WILL MARK BRAINLIEST
    11·1 answer
  • SA = 4π^2h, Where SA is the surface area, R is the radius and H is the height.
    8·1 answer
  • If AK= 14, EK=17, BK= 7 , What is the length of DK? 12.7 8.5 7.0 3.5
    12·2 answers
  • The figure shows a pair of parallel line segments on a coordinate grid:
    5·2 answers
  • Slope= 9; intercept= 2
    13·2 answers
  • Write an equivalent expression by applying the distributive property or drawing a diagram. You MUST show all work
    11·2 answers
  • F(x)=2x 2 −15Find f(−2)Find f(−2)
    13·1 answer
  • Express 9/10 in simplest form.
    12·1 answer
  • If the jackson family drive 135 miles on 6 gallons of gas, how many miles can they can they drive on 9 gallons:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!