You are on page 1of 2

ASSIGNMENT-2

SORTING
1. The best and worst case time complexity of Merge Sort is O(nlogn). Develop a C++ program
from the following algorithm of merge sort which was covered in the lecture.

2. One of the most common application of merge sort is to find the inversion count. The
inversions of an array indicate; how many changes are required to convert the array into its
sorted form. When an array is already sorted, it needs 0 inversions, and in other case, the
number of inversions will be maximum, if the array is reversed.

To solve this problem, we will follow the Merge sort approach to reduce the time
complexity, Implement a C++ program to find the inversion count using merge sort.

[Note: Please find the diagramatic explanation of inversion count on next page]

3. Heap Sort is the most common application of binary heap tree which is said to be the most
efficient sorting algorithm to find the largest or smallest element in an array. Write a C++
program to implement the heap sort.

4. Pre-defined sort() uses intro sort to sort a list of elements. Write a program to implement
intro sort in C++.
Figure1: Inversion Count

You might also like