

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This lecture is part of lecture series for Design and Analysis of Algorithms course. This course was taught by Dr. Bhaskar Sanyal at Maulana Azad National Institute of Technology. It includes: Sorting, Algorithms, Merge, Quick, Divide, Conquer, Base, Case, Subproblems, Recursive, Combine, Array
Typology: Slides
1 / 25
This page cannot be seen from the preview
Don't miss anything!
2
Overview
๏ฌ Divide and Conquer
๏ฌ Merge Sort
๏ฌ Quick Sort
4
Divide and Conquer - Sort
5
Divide and Conquer - Sort
sort the FirstPart sort the SecondPart
sort FirstPart sort SecondPart
7
Merge Sort: Idea
Merge
Recursively sort
Divide into two halves
FirstPart (^) SecondPart
FirstPart SecondPart
8
Merge Sort: Algorithm
Recursive Call
10
Temporary Arrays
Merge-Sort: Merge Example
11
Merge-Sort: Merge Example
i=0 (^) j=
k=
13
Merge-Sort: Merge Example
i=
k=
j=
14
Merge-Sort: Merge Example
i=2 j=
k=
16
Merge-Sort: Merge Example
i=2 (^) j=
k=
17
Merge-Sort: Merge Example
k=
i=2 (^) j=
19
Merge-Sort: Merge Example
i=4 j=
k=
20
Merge(A, left, middle, right)
**1. n 1 โ middle โ left + 1
Space: n Time : cn for some constant c