Segment 16.8 introduced you to an iterative merge sort. This project continues that discussion by…

Segment 16.8 introduced you to an iterative
merge sort. This project continues that discussion by providing more details
about the merge steps.

a. If n is a power of 2, as it is in Figure
16-3, you would merge pairs of individual entries, starting at the beginning of
the array. Then you would return to the beginning of the array and merge pairs
of two-entry subarrays. Finally, you would merge one pair of four-entry
subarrays. Notice that the subarrays in each pair of subarrays contain the same
number of entries. In general, n might not be a power of 2. After merging a
certain number of

Segment 16.8 introduced you to an iterative
merge sort. This project continues that discussion by providing more details
about the merge steps.

a. If n is a power of 2, as it is in Figure
16-3, you would merge pairs of individual entries, starting at the beginning of
the array. Then you would return to the beginning of the array and merge pairs
of two-entry subarrays. Finally, you would merge one pair of four-entry
subarrays. Notice that the subarrays in each pair of subarrays contain the same
number of entries. In general, n might not be a power of 2. After merging a
certain number of pairs of subarrays, you might have too few entries left to
make up a complete pair of subarrays. In Figure 16-12a (on the next page),
after merging pairs of single entries, one entry is left over. You then merge
one pair of two-entry subarrays, and merge the leftover two-entry subarray with
the leftover single entry. Parts b and c of Figure 16-12 show two other
possibilities.

Special cases in an iterative merge sort
after merging one-entry subarrays

Implement an iterative merge sort. Use the
algorithm merge that was given in Segment 16.3. A private method that uses
merge to merge the pairs of subarrays is useful. After the method completes its
task, you can handle the leftovers that we just described.

b. Merging two subarrays requires an
additional temporary array. Although you need to use this extra space, you can
save much of the time that our earlier merge algorithm spends in copying
entries from the temporary array back to the original array. If a is the
original array and t is the temporary array, you first merge subarrays of a
into the array t. Instead of copying t back to a and continuing the merge, you
determine subarrays of t and merge them into a. If you can do this an even
number of times, no additional copying is necessary. Make these changes to the
iterative merge sort that you wrote in Part a.

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more