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
NEED CORRECT ANSWER...
Misha Larkins [42]

39.50-23.76-2.57-1.49=11.68

take the sales and subtract the expenses

6 0
3 years ago
What is the meaning of percent? How can percent be estimated and found?
Luden [163]

Answer:

Percent means the number out of 100

use the formula ( Value you got / Original value) X 100

for percentage increase or decrease = (Change in value / original value) X 100

Step-by-step explanation:

8 0
2 years ago
A professor gives a statistics exam. The exam has 100 possible points. The scores for the students in the second classroom are a
Vesna [10]

Answer:

N = 9

M = 87.11

Step-by-step explanation:

According to the situation, the data provided and the solution are as follows

The scores for the student in the classroom is

= 88 88 92 88 88 72 96 88 84

The different student's number of scores is 9

The solution of new n and M is shown below:-

Sample size (n) = 9

Sample mean (m) is

= \frac{Sum\ of\ all\ data\ values}{Sample\ size}

= \frac{88 + 88 + 92 + 88 + 88 + 72 + 96 + 88 + 84}{9}

= \frac{784}{9}

= 87.11

3 0
2 years ago
Calculate the length of ac to 1 decimal place
ElenaW [278]

Answer:

it would be in the 100eds place

Step-by-step explanation:

7 0
3 years ago
Read 2 more answers
What is the type slope?<br> Please help
nadya68 [22]

Answer:

its positive

Step-by-step explanation:

because the line going upward

6 0
2 years ago
Read 2 more answers
Other questions:
  • Write y=-3x^2+12x-21 in vertex form
    8·2 answers
  • Math question number 2:hard! Help!!!!!!
    14·2 answers
  • Scientific notation for <br> 78 million
    12·2 answers
  • What prime numbers make 32 being added up
    9·2 answers
  • 30 POINTS!!!
    7·1 answer
  • What is the reciprocal of 9/7?
    15·2 answers
  • John wants to join a gym so that he can work out during the evenings. There are two gyms in his town that he is considering. Ext
    8·2 answers
  • Which of the following best describes the pattern in the diagram as you move
    5·2 answers
  • Hi please help i’ll give brainliest
    10·1 answer
  • Question on Pic Thank You!!!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!