100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

data structures and algorithms notes

Rating
-
Sold
-
Pages
8
Uploaded on
19-11-2022
Written in
2022/2023

CP164 data structures and algorithms notes










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
November 19, 2022
Number of pages
8
Written in
2022/2023
Type
Class notes
Professor(s)
David brown
Contains
All classes

Content preview

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
CA$36.15
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
nimraharain

Get to know the seller

Seller avatar
nimraharain Wilfrid Laurier University
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions