subject

We are given an array that contains N numbers. We want to determine if there are two numbers whose sum equals a given number K. For instance, if the input is 8, 4, 1, 6, and K is 10, then the answer is yes (4 and 6).

A number may be used twice. Do the following: a. Give an O(N2) algorithm to solve this problem.

b. Give an O(N logN) algorithm to solve this problem. (Hint: Sort the items first. After that is done, you can solve the problem in linear time.)

c. Code both solutions and compare the running times of your algorithms.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 15:10
Awould be a misconfiguration of a system that allows the hacker to gain unauthorized access, whereas is a combination of the likelihood that such a misconfiguration could happen, a hackerā€™s exploitation of it, and the impact if the event occurred.
Answers: 3
question
Computers and Technology, 22.06.2019 02:30
Larry sent an email to andy. andy didn't open larry's email but still understood what the message was. how did andy determine the message without opening the email?
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
What process should be followed while giving a reference? sam has given a reference of his previous manager in his resume. sam should him in advance that the potential employers will him.
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
After making a powerpoint presentation about a new line of clothing designs, henri notices that he used the word ā€œgorgeousā€ on nearly every slide. what would be the  best  way to add more variety to his wording by using tools within powerpoint? using the thesaurus under the view tab, and then using the find dialog box to find and replace every instance of ā€œgorgeousā€using the spelling checker under the view tab, and then using the find dialog box to find every instance of ā€œgorgeousā€ and change some of themusing the thesaurus under the review tab, and then using the find dialog box to find every instance of ā€œgorgeousā€ and change some of themusing the spelling checker under the review tab, and then using the find dialog box to find and replace every instance of ā€œgorgeousā€
Answers: 2
You know the right answer?
We are given an array that contains N numbers. We want to determine if there are two numbers whose s...
Questions
question
Mathematics, 08.12.2020 01:50
question
Mathematics, 08.12.2020 01:50
Questions on the website: 13722363