Select Page

George Mason University Java Programming A1 and A2 Input Project

Question Description

Please write this program and have some comments for me to understand how you did it.

please find the input and output in input word document

Programming Task 2.The input consists of n numbers a1, a2, . . . , an.The goal is to determine a value t that can be obtained by adding two of these numbersand, moreover, the number of pairs of these numbers that add up to t is the largest possible(in other words, you need to find the most popular sum of two numbers in the list). Formally,your program will find a t such that the size of the set {(i, j) | i < j, ai+aj = t} is maximumamong all possible t’s. For example, for 2, 7, 3, 1, 5, 6, we have: 2 + 6 = 7 + 1 = 3 + 5. Thisis the largest number of pairs that sum to the same number, and, therefore, t = 8.Describe an O(n2log n) algorithm for this problem, and implement it in Java or C++.(For an example of what I mean by “Describe …,” see the NOTE 2 at the end of thisdocument). You must explain clearly why your algorithm runs in O(n2log n) time.Hint: The number of pairs (ai, aj ) with i < j isn2 = n(n ? 1)/2 = ?(n2), and so youcan afford to consider all these pairs.Input specification: The input consists of two lines. The first line contains a positiveinteger n. The second line contains integers a1, a2, . . . , an, separated by spaces. You mayassume that the input integers fit in int. You may also assume that n is positive and notlarger than 10,000.Output specification: the output contains a single line with the number t. If there aremultiple possibilities for t, output the smallest one.Sample inputs (see files) :input-2.1.txt input-2.2.txtSample outputs :answer2.1.txt answer-2.2.txtTest your program on the following inputs:input-2.4.txt input-2.6.txtand report the results you have obtained.NOTE 2: You can find an example of what I mean by “Describe an algorithm …” athttps://www.geeksforgeeks.org/find-the-element-tha…

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now