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
Maksim231197 [3]
3 years ago
6

You are given an array of integers "array []" and an input "x". you have to find if there are any two numbers in your array such

that the sum of their square equals to x2 . in other words, you have to find out if there is any pair of i,j such that array[i]2 + array[j]2 = x 2 . if there are such pairs, you should print all such (i,j). otherwise print "there are no such pairs". example: array []: 6, -4, 6, 3, 9, 0, -1, -9, 2, 6 x: 5 you have 1 pair: (-4) 2 + (3) 2 = 5 2 so, your output would be corresponding array indices: (1, 3) note: the array size is 10 and you have to get the elements of the array from
Mathematics
1 answer:
Vesnalui [34]3 years ago
3 0
Given an integer array a, size n, and an input integer value x..  Need to find all pairs of members a[i], a[j] such that (a[i],a[j],x) form a Pythagoras triplet, with x>a[i], a[j].

We need a double loop, the outer loop for a[i], and the inner loop finds a[j].
Here's a pseudocode.

int i, j, x, i2, x2, count=0; 
input x;
x2=x*x;   // economizing on cycles
if x<0 {x=-x};
for i=1 to n-1 {
  if x>=i {      // skip processing the impossible
    i2=i*i;      // economizing on cycles     
    for j=2 to n {
      if x>=j {     // skip processing the impossible
         if i2+j*j==x2 {
            count++;
            print(i,j);
         }
      }
    }
  }
}
if count==0 { print("there are no matched pairs");

It will have a similar complexity as a bubble sort, n^2/2.


You might be interested in
A drum of oil has a height of 4 ft and a radius of 1.2 ft. The oil cost $22 per ft³.
nadezda [96]

$397.9 is the answer, i took the test today

6 0
3 years ago
Read 2 more answers
Given f(x)=4x^3+7x^2-7x-10 factor f(x), given that -1 is a zero
stira [4]
If - 1 is a zero then
(x + 1)
is a factor.

Dividing with this factor using the long division approach, we get the quadratic factor to be,

4 {x}^{2}  + 3x - 10
(see attachment).

We can rewrite the polynomial as
f(x) = (x  + 1)(4 {x}^{2}  + 3x - 10)

We can further factor as

f(x) = (x + 1)(4 {x}^{2}  - 5x + 8x - 10)
That is

f(x) = (x + 1)(x  +  2)(4x - 5)

7 0
4 years ago
If tim spends 1/3 each weekday sleeping and about 7/24 each weekday in school what fraction of a weekday does Tim spend either s
Ganezh [65]
Tim spends 1/3 each weekday sleeping and 7/24 in school. We can write 1/3 as 8/24 so we have a common denominator. Now we can see that Tim sleeps for 1/24 time of a weekday more then he spends in school.

I hope that's what you meant.
3 0
4 years ago
Help me with this math problem, I need someone to guide me through it I don’t understand what I’m supposed to do first
natita [175]

Answer:

see below

Step-by-step explanation:

The parent function is x^2 which is a parabola at vertex (0,0)

g(x) = ( x+3) ^2

y = f(x + C) C > 0 moves it left  

So the parabola is shifted to the left 3 units

h(x) = -( x+3) ^2

y = −f(x)  

Reflects it about x-axis

Means flip it about the x axis

7 0
3 years ago
Could someone help me with a question?
11111nata11111 [884]
Whats the question ill be happy to help
5 0
3 years ago
Other questions:
  • You are going to use an incline plane to lift a heavy object to the top of a shelving unit with a height of 6 ft. The base of th
    12·1 answer
  • Please help! ...................
    7·1 answer
  • A 7-foot tall stop sign creates a shadow that is 2 feet long. At the same time, a utility pole creates a shadow that is 11 feet
    6·1 answer
  • Barbie is analyzing a circle, y2 + x2 = 16, and a linear function g(x). Will they intersect?
    5·2 answers
  • Tony checked out 4 books from the library. He returned the books 3 days late. The fine for late books is $0.05 a day for each bo
    10·2 answers
  • Solve the following<br> if 7+2x all divided by three equals 5 what is x?
    14·2 answers
  • A company’s mean salary is $65,000 with a standard deviation of $6,000. What is the probability that an employee makes between $
    14·1 answer
  • Angad was thinking of a number. Angad doubles it, then adds 8 to get an answer of 68.4. What was the original number?​
    14·2 answers
  • What is the value of 3^ -2 as a fraction
    10·1 answer
  • Please do this thank you will give brain liest if correct..
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!