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
If a seed is planted, it has a 85% chance of growing into a healthy plant.
9966 [12]
14.16 chances of 1 to not grow
7 0
2 years ago
Pre college need help
jek_recluse [69]

Answer:

check online for more information

5 0
2 years ago
PLEASE HELP GIVING 50 POINTS!!
PSYCHO15rus [73]

Answer:

  y = 18

Step-by-step explanation:

Direct variation means y will change by the same factor x does. When x changes by a factor of 15/10 = 1.5, the value of y will change by that same factor

  x = 10, y = 12

  x= 15, y = 1.5×12 = 18

The new value of y is y = 18.

_____

Written as a proportion, you have ...

  y/15 = 12/10

  y = 15×12/10 = 18

__

Written as a direct variation equation, you have ...

  y = kx

  12 = k·10   ⇒   k = 1.2

  y = 1.2·15 = 18 . . . . for x=15

4 0
2 years ago
the cost of a ticket t to a concert with a 3% sales tax can be represented by the expression t+0.03t. simplify the expression. t
Leokris [45]
.03 time 72 then add 72 or just do 1.03 time 72
4 0
3 years ago
if you're currently making $6.75 per hour and you were offered a new job that pays $7.47 per hour, what will be your percent of
worty [1.4K]

Answer:

10.67% increase

Step-by-step explanation:

We can find percent increase with (difference/original) x 100

7.47 - 6.75

= 0.72 (difference)

(0.72/6.75) x 100

= 10.67% increase

5 0
3 years ago
Other questions:
  • What is the product 1/5 x 2 ?
    15·1 answer
  • Express ln 32 - ln 8 as a single natural logarithm
    7·2 answers
  • Elizabet is selling ham at a farmers market
    8·1 answer
  • Evaluate the expression for x = -3 and y = 4<br> 3x2 – 2xy
    13·1 answer
  • (08.06)
    7·1 answer
  • I NEED HELP ASAP Before School! Please. One/Two Stepp Equation Word Problems | Define The Variable For Each Problem.
    11·2 answers
  • Find the area of a triangle with base 31 inches and height 17 inches
    10·2 answers
  • *Please Help!*
    14·1 answer
  • How many moles of hydrogen are produced from a reaction involving 156.4 g of zinc and excess hydrochloric acid?
    14·1 answer
  • What is the value of the missing angle?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!