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
Annette [7]
3 years ago
12

Given an unsorted array of distinct positive integers A[1..n] in the range between 1 and 10000 and an integer i in the same rang

e. Here n can be arbitrary large. You want to find out whether there are 2 elements of the array that add up to i. Give an algorithm that runs in time O(n).
Engineering
1 answer:
AnnZ [28]3 years ago
7 0

Answer:

Explanation:

Arbitrary means That no restrictions where placed on the number rather still each number is finite and has finite length. For the answer to the question--

Find(A,n,i)

for j =0 to 10000 do

frequency[j]=0

for j=1 to n do

frequency[A[j]]= frequency[A[j]]+1

for j =1 to n do

if i>=A[j] then

if (i-A[j])!=A[j] and frequency[i-A[j]]>0 then

return true

else if (i-A[j])==A[j] and frequency[j-A[j]]>1 then

return true

else

if (A[j]-i)!=A[j] and frequency[A[j]-i]>0 then

return true

else if (A[j]-i)==A[j] and frequency[A[j]-i]>1 then

return true

return false

You might be interested in
An ideal gas initially at 300 K and 1 bar undergoes a three-step mechanically reversible cycle in a closed system. In step 12, p
Veseljchak [2.6K]

Answer:

Ts =Ta E)- 300(

569.5 K

5

Q12-W12 = -4014.26

Mol

AU2s = Q23= 5601.55

Mol

AUs¡ = Ws¡ = -5601.55

Explanation:

A clear details for the question is also attached.

(b) The P,V and T for state 1,2 and 3

P =1 bar Ti = 300 K and Vi from ideal gas Vi=

10

24.9x10 m

=

P-5 bar

Due to step 12 is isothermal: T1 = T2= 300 K and

VVi24.9 x 10x-4.9 x 10-3 *

The values at 3 calclated by Uing step 3l Adiabatic process

B-P ()

Since step 23 is Isochoric: Va =Vs= 4.99 m* and 7=

14

Ps-1x(4.99 x 103

P-1x(29x 10)

9.49 barr

And Ts =Ta E)- 300(

569.5 K

5

(c) For step 12: Isothermal, Since AT = 0 then AH12 = AU12 = 0 and

Work done for Isotermal process define as

8.314 x 300 In =4014.26

Wi2= RTi ln

mol

And fromn first law of thermodynamic

AU12= W12 +Q12

Q12-W12 = -4014.26

Mol

F'or step 23 Isochoric: AV = 0 Since volume change is zero W23= 0 and

Alls = Cp(L3-12)=5 x 8.311 (569.5 - 300) = 7812.18-

AU23= C (13-72) =5 x 8.314 (569.3 - 300) = 5601.53

Inol

Now from first law of thermodynamic the Q23

AU2s = Q23= 5601.55

Mol

For step 3-1 Adiabatic: Since in this process no heat transfer occur Q31= 0

and

AH

C,(T -Ts)=x 8.314 (300- 569.5)= -7842.18

mol

AU=C, (T¡-T)= x 8.314 (300

-5601.55

569.5)

mol

Now from first law of thermodynamie the Ws1

J

mol

AUs¡ = Ws¡ = -5601.55

3 0
3 years ago
True power can only be measured across what?
loris [4]

Answer: mets

Explanation: meets are good

6 0
3 years ago
Read 2 more answers
A steel rule can be used to check for
MAXImum [283]
I THINK THE ANSWER IS B BUT IM NOT SURE OK BYE
3 0
3 years ago
If the channel-Length modulation effect is neglected, ID in the saturation region is considered to be independent of VDS
djverab [1.8K]
The answer is true because if the effect is neglected, the saturation id region is considered true
4 0
3 years ago
How should you mark a component listed on the VCU form that
Anna [14]
I’m not that shareholding about it but I think the answer is C mark it green I hope I don’t get it rong
7 0
3 years ago
Other questions:
  • Two advantages of deforming steel at room temperature rather than at elevated temperatures are: (select 2 answers from the optio
    13·1 answer
  • If i eat myself will I get twice as big or disappear completely?
    7·1 answer
  • An aircraft component is fabricated from an aluminum alloy that has a plane strain fracture toughness of 40 MPa . It has been de
    7·1 answer
  • In water and wastewater treatment processes a filtration device may be used to remove water from the sludge formed by a precipit
    10·1 answer
  • For each resource, list 3 examples of how it would be used to produce a hamburger. Think outside of the “hamburger” box!
    12·1 answer
  • THIS IS NOT AN ACADEMIC QUESTION, but who was the bitter of 1987 in FNAF?
    6·2 answers
  • PLEASE HELP AND ANSWER MY OTHER QUESTIONS!,
    7·1 answer
  • Somebody help me!! It’s due today
    9·1 answer
  • Explain what the engineering team should advise in the following scenario.
    7·1 answer
  • Joey has a car that uses the hand crank to open the windows. Joey is wondering where the energy comes from to open the windows.T
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!