Assignment 1 (Task B) Rohan Taneja
Sorting is process of arranging a list of elements in increasing or decreasing Sequence.
Technically, Sorting can be done by a comparing 2 elements of list and placing elements on
different location as required for ordering. The >,
element in list.
E.G. : – Below is list of elements without any order:
45, 12, 71, 63, 98, 59
Sorting in ascending order: 12, 45, 59, 63, 71, 98
Sorting in descending order: 98, 71, 63, 59, 45, 12
We need a list to do sorting. List can be an Array, Linked List, Array List or Vector.
Sorting can be done by using different techniques like bubble sort, Insertion Sort, Quick Sort etc.
All sorting techniques have different speed and algorithm for sorting. Each sort algorithm has
different time space complexity which makes it to run with different speed and take different
memory of CPU.
Sorting is something very common thing to be used. There are so many examples where we need
sorting in real life. Finding students position in class need sorting. Looking for products to shop
online we need to do sorting with different filters like price from low to high, price from high to
low, latest products etc. Hence sorting is one of the important parts of data structures.
Now the most important question is, which sorting technique we should use out of numerous
techniques. Most of the libraries use most efficient sorting algorithm to save time and space.
Also it depends upon requirement and situation and number of elements you are going to sort.
In this assignment, we are going to discuss Merge sort in detail.
Assignment 1 (Task B) Rohan Taneja
Understanding Merge Sort
Merge Sort is a technique of Divide and Conquer. In this technique, system divides list in two
parts, then calls itself to divide each part into further 2 parts until each element separates from
list and then merges elements in sorted manner to get back the two sorted lists. In last we will
have final list with all sorted elements. So we can say merge sort technique first divides the list
into half and then combines them in a sorted order.