0% found this document useful (0 votes)
45 views11 pages

Lecture 1.2.5

The document discusses the merge sort algorithm. It begins by defining merge sort as a sorting technique that uses a divide and conquer approach with a worst-case time complexity of O(n log n), making it efficient. It then explains that merge sort works by dividing an array into equal halves and then merging the halves together in a sorted manner. The document provides pseudocode to demonstrate the steps of merge sort including dividing, merging, and examples. It concludes with discussing the algorithm's complexity analysis and references.

Uploaded by

Ravesh Rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views11 pages

Lecture 1.2.5

The document discusses the merge sort algorithm. It begins by defining merge sort as a sorting technique that uses a divide and conquer approach with a worst-case time complexity of O(n log n), making it efficient. It then explains that merge sort works by dividing an array into equal halves and then merging the halves together in a sorted manner. The document provides pseudocode to demonstrate the steps of merge sort including dividing, merging, and examples. It concludes with discussing the algorithm's complexity analysis and references.

Uploaded by

Ravesh Rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIVERSITY INSTITUTE OF

ENGINEERING
DEPARTMENT OF COMPUTER
SCIENCE AND ENGG.
Bachelor of Engineering (Computer Science & Engineering)
DATA STRUCTURES 21CSH-211

ARRAY IN DATA STRUCTURE DISCOVER . LEARN . EMPOWER


Agenda

•Sorting
• Merge Sort

2
Merge Sort
• Merge sort is a sorting technique based on divide and conquer technique.
With worst-case time complexity being Ο(n log n), it is one of the most
respected algorithms.
• Merge sort first divides the array into equal halves and then combines them
in a sorted manner.
Algorithm
Merge sort keeps on dividing the list into equal halves until it can no more be
divided. By definition, if it is only one element in the list, it is sorted. Then,
merge sort combines the smaller sorted lists keeping the new list sorted too.
Step 1 − if it is only one element in the list it is already sorted, return.
Step 2 − divide the list recursively into two halves until it can no more be
divided.
Step 3 − merge the smaller lists into new list in sorted order.

3
• Merge sort is a sorting technique based on divide and conquer
technique. With worst-case time complexity being Ο(n log n), it is
one of the most respected algorithms.
• Merge sort first divides the array into equal halves and then
combines them in a sorted manner.

4
• How Merge Sort Works?
• To understand merge sort, we take an unsorted array as the
following −

5
6
Algorithm

• Merge sort keeps on dividing the list into equal halves until it can no
more be divided. By definition, if it is only one element in the list, it
is sorted. Then, merge sort combines the smaller sorted lists keeping
the new list sorted too.
• Step 1 − if it is only one element in the list it is already sorted,
return.
• Step 2 − divide the list recursively into two halves until it can no
more be divided.
• Step 3 − merge the smaller lists into new list in sorted order.

7
Example

8
Complexity Analysis
References

• Lipschutz, Seymour, “Data Structures”, Schaum's Outline Series, Tata McGraw Hill.
• Goodrich, Michael T., Tamassia, Roberto, and Mount, David M., “Data Structures and Algorithms in C++”, Wiley
Student Edition.
• https://www.tutorialspoint.com/data_structures_algorithms/algorithms_basics.htm
• https://www.cs.utexas.edu/users/djimenez/utsa/cs1723/lecturehtml
• https://www.w3resource.com/php-exercises/searching-and-sorting-algorithm/searching-and-sorting-algorithm-exercise-4.
php
• https://www.programiz.com/dsa/merge-sort
• https://www.geeksforgeeks.org/binary-search/

10
THANK YOU

You might also like