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
If you save a Word file as a Web page, what type of file will it be?
Mnenie [13.5K]

Answer:

When you save a Microsoft Word document as a Web page (on the File menu, click Save as Web Page), Word automatically converts the page to HTML (Hypertext Markup Language), the language used by Web browsers to read Web pages.

Explanation:

7 0
3 years ago
Both computers and people handle information using which processes?
GenaCL600 [577]

Answer:

Explanation:

Both computer and human use the process of encoding, storage and retrieval to process information.

Encoding is the process of putting the information in a format that will be understood by either the human or the computer. The information is then stored in the memory. Both the computer and human have memory where the information will be store. When the information is needed, it is then retrieved from the location in which it was stored.

6 0
3 years ago
What are the process of boots up a computer?​
Sindrei [870]

Answer:

in computer booting is the process of starting a computer it can be initiated By hardware such as button press or by a software command after it is switched on a computer central processing unit ( CPU)

3 0
3 years ago
Item 3Item 3 John works for Internal Computer Specialists, which focuses on helping small business owners resolve MIS infrastruc
White raven [17]

Answer:

Replacing computer parts.

Explanation:

John replaces faulty computer parts, such as DVDs, hard drives, ram cards, wires etc. John can also replace the whole motherboard or clean it (for dust).

Computer parts not functioning properly or dying is a common problem in computer systems. Motherboard, the circuit that holds all the components of a computer, like CPU, Ram and Hard disk, can also fail or die.

5 0
3 years ago
What does the ‘random’ part of Random Access Memory refer to?
Tems11 [23]

Answer:

it means it store a few in information randomly because it process different information at the same time

7 0
3 years ago
Other questions:
  • What is basic function of an operating system?
    10·2 answers
  • 7. Write a program in C to display the string "ARRAY" in the following format : A AR ARR ARRA ARRAY
    5·1 answer
  • In which utility is the file search option found in windows
    5·1 answer
  • What is information systems​
    5·1 answer
  • Write a program that will manipulate Rectangle objects for which you will create a Rectangle class.
    5·1 answer
  • George enters the types of gases and the amount of gases emitted in two columns of an Excel sheet. Based on this data he creates
    6·1 answer
  • The measure means to determine the exact size, amount, or distance of something
    11·1 answer
  • What is memory address map​
    7·1 answer
  • A client is looking to maximize value from its Cloud investments by baselining, profiling, and prioritizing its human capital ne
    9·1 answer
  • which type of virtual machine (vm) takes advantage of unused capacity in data centers at a much lower cost than regular vms of s
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!