Checkout
checkout
view
Your Cart Your Cart: item(s)
Add to Shopping Cart
$2.19 Instant Download
Computer Science, Data Structures and Algorithms
Other

explanation of solution



The solution seems to be the the following, but I need a more in-depth explanation, particularly on why we should use merge sort and binary sort.

Here is the problem at a high level (you can look at the attachment for more detail):
Describe a (n log_2 n) time algorithm that, given a set S of n real numbers
and another real number x, determines whether or not there exist two
elements in S whose sum is exactly x.


Solution:
Sort the array using an algorithm of order O(n log n) (You can use mergesort but
you cannot use quicksort)
Then for every element y in the array binary search the sorted array for x - y

O(n log n) + O(n log n) = O(n log n)

Attachments
sum-of-2-numbers.pdf  View File

By OTA:  Xiao Liu, MS

OTA Rating:  4.7/5

Your Price:  $2.19  (original value ~$15.96)

What's included:

  • Plain text response
$2.19 Download Add to Cart

Add to Shopping Cart
$2.19 Instant Download
Walmart Case study question - What do you think the potential impact of WalMart.com will be on the parent company's efforts to expand internationally?

Page generated in 0.0138 seconds

About Us ·  Contact Us ·  Samples ·  Solutions ·  Legal Terms and Conditions ·  Privacy Policy

©2008 SolutionLibrary.com

Search for Solutions About Us Samples