subject

Problem Description It is the same problem as in Exercise1, but you have to write a different program. We are given an input file that contains
word Sumofk,
"target" number K,
and a sequence of N numbers.
We want to determine if there are two numbers whose sum equals the given "target" number K.
For instance, if the input file contains
//word SumOfK II
"target" number K I/
sequence of N numbers 10 8416
We know from the file that K is 10, sequence of numbers is 8 4 16, and number of elements N is 4 (we can count numbers). In this case, the answer is yes, there are two such numbers (4 and 6), because 4+6 is 10
One number may be used twice (doubled). If the input file is SumOfK 10 8453 the answer is also yes, because 5+5 is 10.
Lab1 Program Devise and implement an O(N log(N)) algorithm to solve the problem. Split it in two parts-sort the items first, after it is done, you have to search for numbers in O(N). See https://en. wikipedia. org/wiki/Heapsort Code the solution. Read data from input file inX. txt and print the results to output file outx. txt (where X is 1, 2,.. The differences between Lab1 and Exercise1 are
1. The algorithm has to consist of two parts-O(N"log(N)) sorting and O(N) searching
2. The output file has also to contain the sorted list of input numbers

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:40, cutybrain6054
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, GEEKLIFE6598
After you present a proposal, the committee starts asking you questions, some beyond the strict focus of your proposal. they ask questions about implications in other fields and knowledge about other fields. you are asked to redo your proposal. what is most likely missing? breadth of material depth of material clarity of material details of material
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, Gearyjames8
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
image
Computers and Technology, 23.06.2019 21:30, quintonps12
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
You know the right answer?
Problem Description It is the same problem as in Exercise1, but you have to write a different progr...

Questions in other subjects: