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

An integer x and a sequence b,...b, of integers is given. The problem is to find indices i, j, such that b,+b, = x . Suggest a d

ata structure and/or an algorithm for answering such questions and analyze their complexity. (Try to optimize the asymptotic complexity of your solution.)
Computers and Technology
1 answer:
stepladder [879]3 years ago
8 0

Answer:

Algorithm -

1.Firstly, Sort(b)

2.Then, Set i=0,j=n-1,flag=1

3.When, while(i<j)

4.Then, Set if b[i] + b[j] == x

5.Then, flag=0

6.Then, break the following condition.

7.Set if b[i] + b[j] < x //when the following condition is true

8.Then, the value of i increase i=i+1

9.Either, else

10Then, the value of j decrease j=j-1

11.Then, Set if flag == 0

12.And print b[i],b[j]

13.Otherwise else

14. no such pair exists.

Time complexity analysis -

Sort - O(nlogn)

while loop - O(n)

Total - O(nlogn)+O(n) = O(nlogn)

Explanation:

Firstly, sort these sequence(array) of the integers. It takes O(N log N) time if done with the Merge Sort or the Heap Sort or any other sorting the algorithm within less time complexity.

After that, take two indices one at the start and one at the end. Traverse these array from the start to the end based on the sum of the values.

You might be interested in
Which frequency will 802.11n work on if on a single-link network?
Allushta [10]

802.11n can function in "mixed mode" on the 2.4 GHz frequency, with a theoretical maximum speed of 300 Mbps, or on the 5 GHz frequency.

<h3>What do you mean by frequency?</h3>

In the case of electrical current, frequency is the number of times a sine wave repeats or completes, a positive-to-negative cycle.

802.11n can operate in "mixed mode" on the 2.4 GHz frequency, which will support just 802.11b or 802.11g-capable systems but will slow the entire network down to the maximum speed of the earliest standard connected, at a theoretical maximum speed of 300 Mbps.

Learn more about the single-link network:

brainly.com/question/4272298

#SPJ1

8 0
2 years ago
What was the pascaline used for?​
Alex_Xolod [135]

Answer:

Math like multiplication, addition, division, and subtraction

3 0
3 years ago
What TCP message will be generated for an incoming SYN request for which is there no matching LISTENING port
tresset_1 [31]

Answer:

"Connection Refused"

Explanation:

This is the error message that is returned when the server is not listening on the correct port, or the server is offline.

Cheers.

7 0
3 years ago
How many shared keys are required for a company of 70 employees who all need to communicate securely with each other?
kiruha [24]
I Think The Answer Would Be B Or D

7 0
3 years ago
Who uses super computer
Delvig [45]
Aerospace, petroleum, and automotive industries
3 0
3 years ago
Other questions:
  • Given that Jamie worked 50 hours (Hours = 50) last week and earns $10.00 an hour (Rate = 10), how much did Jamie earn last week,
    11·1 answer
  • Which of the following is NOT a function of the Web Accessibility Initiative​ (WAI)? A. Offering links to a variety of software
    10·1 answer
  • Write a method called swapPairs that switches the order of values in an ArrayList of strings in a pairwise fashion. Your method
    9·1 answer
  • What does email etiquette mean?
    14·1 answer
  • When protecting a worksheet all cells are locked by default.?
    10·1 answer
  • Yahoo and Google are examples of __________ used to perform Internet research.
    14·2 answers
  • pDevices used to prevent data from being written to a disk can connect to a computer through FireWire, SATA, PATA, and SCSI cont
    10·1 answer
  • Select the correct answer
    15·1 answer
  • Liam noticed someone had accessed his social media account and made several posts without his knowledge. Which of the following
    13·1 answer
  • You should move around and take a rest for 30 minutes every 5 minutes.<br><br>True Or False​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!