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
Please help me out :P
Veseljchak [2.6K]

cos θ = \frac{-4\sqrt{65} }{65}, sin θ = \frac{-7\sqrt{65} }{65}, cot  θ  = 4/7, sec  θ = \frac{-\sqrt{65} }{4}, cosec  θ  = \frac{-\sqrt{65} }{7}

<h3>What are trigonometric ratios?</h3>

Trigonometric Ratios are values of all the trigonometric functions based on the value of the ratio of sides in a right-angled triangle.

Sin θ: Opposite Side to θ/Hypotenuse

Tan θ: Opposite Side/Adjacent Side & Sin θ/Cos

Cos θ: Adjacent Side to θ/Hypotenuse

Sec θ: Hypotenuse/Adjacent Side & 1/cos θ

Analysis:

tan θ = opposite/adjacent = 7/4

opposite = 7, adjacent = 4.

we now look for the hypotenuse of the right angled triangle

hypotenuse = \sqrt{7^{2} + 4^{2} } = \sqrt{49+16} = \sqrt{65}

sin θ = opposite/ hyp = \frac{7}{\sqrt{65} }

Rationalize, \frac{7}{\sqrt{65} } x \frac{\sqrt{65} }{\sqrt{65} } = \frac{7\sqrt{65} }{65}

But θ is in the third quadrant(180 - 270) and in the third quadrant only tan and cot are positive others are negative.

Therefore, sin θ = - \frac{7\sqrt{65} }{65}

cos   θ  = adj/hyp = \frac{4}{\sqrt{65} }

By rationalizing and knowing that cos  θ  is negative, cos θ  = -\frac{-4\sqrt{65} }{65}

cot θ  = 1/tan θ  = 1/7/4 = 4/7

sec θ  = 1/cos θ  = 1/\frac{4}{\sqrt{65} } = -\frac{-\sqrt{65} }{4}

cosec θ  = 1/sin θ  = 1/\frac{\sqrt{65} }{7} = \frac{-\sqrt{65} }{7}

Learn more about trigonometric ratios: brainly.com/question/24349828

#SPJ1

5 0
2 years ago
A Ferris wheel has a radius of 72 feet. What is the distance a passenger will travel one time around the Ferris Wheel
rosijanka [135]
31 seconds it will take to get around without it stopping
6 0
3 years ago
Write an expression that sho how to use the halving and doubling strategy to find 28×50
swat32
28x50
14x100
7x200=14,000
8 0
4 years ago
2 2/3× 4 1/5 help me plzzzzz!!!
Rus_ich [418]
First let's multiply the whole numbers 2 and 4. Obviously that is 8. Now let's put aside the whole number and multiply fractions.

2/3 x 1/5 is equal to 2x1/3x5 so it's 2/15 which is already in simplest form. 

So your final answer is 8 and 2/15 :)

If this was helpful would you mind marking mine as brainliest please? It helps me rank up a lot!
8 0
3 years ago
Does this graph represent a function?Why or why not?
cestrela7 [59]

No, it does not have a straight line. (A)


4 0
4 years ago
Read 2 more answers
Other questions:
  • A tip is a percent of a bill that is added to the total to pay for service coles dinner bill is $15 and he want a to leave an 18
    8·1 answer
  • If Mrs Murphy separates her class into groups of 4 students each, 1 student is left over. If she separates her class into groups
    15·1 answer
  • The library has thirteen
    8·1 answer
  • What is the ratio of the number of days in the week that do not begin with the letter "T" to the number of days in the week that
    11·2 answers
  • Which line plot displays a data set with an outlier?
    5·2 answers
  • What is the greatest common factor of 9 and 14?
    10·2 answers
  • Find the inequality represented by the graph
    6·1 answer
  • Simplify the given expression below:<br> (4 + 21) – (1 – 71)
    15·2 answers
  • Paragraph
    9·1 answer
  • 3. In a circular park with a radius of 250 m there are 7 lamps whose bases are circles with
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!