100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
data structures and algorithms notes CA$36.62   Add to cart

Class notes

data structures and algorithms notes

 6 views  0 purchase

CP164 data structures and algorithms notes

Preview 2 out of 8  pages

  • November 19, 2022
  • 8
  • 2022/2023
  • Class notes
  • David brown
  • All classes
All documents for this subject (3)
avatar-seller
nimraharain
CP164 LECTURE 15 NOTES



The Merge Sort
This algorithm uses the divide and conquer approach which is an important
algorithmic technique in Computer Science. This algorithm splits an array up
into two smaller arrays, recursively sorts the two smaller arrays, and
finally merges the smaller arrays back into the big array. Merge sort is a stable
sort.


Merge Sort Algorithm
The merge sort algorithm works as follows. If n=1, there is only one element to
sort, and we are done. Otherwise it divides the array into two halves, and
recursively applies merge sort on the first half and on the second half. This
gives two sorted halves, which can then be merged together.

The main operation in this algorithm is merging the two sorted arrays. The
following figure shows the process of merging two sorted arrays. The merging
algorithm takes two sorted input arrays and one output array. It traverses the
input arrays, copying the smaller of the two into the output array in each
iteration. When either input array is copied completely to the output, the
remainder of the other array is copied to the output array.

, Merging Two Sorted

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller nimraharain. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$36.62. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79650 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$36.62
  • (0)
  Add to cart