(5/5)

Hire Me
(5/5)

Hire Me
(5/5)

Hire Me
(5/5)

Hire Me

# Given an array of integers (not necessarily sorted), return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution

INSTRUCTIONS TO CANDIDATES
###### ANSWER ALL QUESTIONS

Problem 1: Two Sum

Problem Description: Given an array of integers (not necessarily sorted), return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

For example, if you are given an array [2, 7, 11, 9] with a target 9, then you will return [0, 1] since the first two numbers add up to 9. It is important that you solve this problem using divide and conquer and recursion. That is, you must divide the original problem into subproblems, recursively solve the subproblems, and then combine the solutions to the subproblems to obtain the solution to the original problem.

Your solution should take O(n log n) time. If you don’t use divide and conquer and recursion then you will not get any points for this assignment. The following has to be given.

Submission should contain a code file, and a pdf (report)

(a) Give the pseudocode for your solution. Also explain in English why your solution works. (30 points)

(b) Show correctness of your algorithm and analyze its complexity. (20 points).

(c) Code up your solution in C++ Your code should be well commented. Your code should compile, otherwise no points. (50 points)

Hints: • Figure out how to efficiently check for the solution if the input is sorted.

• Figure out a way of solving the problem in O(n log n) time by using divide and conquer. The main idea is to use an approach like MergeSort.
• Return only the two distinct indices (assume there is exactly one solution)

## Related Questions

##### . The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

##### . Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

##### . The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

##### . Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

##### . The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

292 Experts Online