0% found this document useful (0 votes)
31 views12 pages

Bwu - Bta - 22 - 416 - Subrata Dhara Bta

The document compares and analyzes different sorting algorithms. It discusses internal sorting algorithms like bubble sort, selection sort, quick sort, and insertion sort. It also covers external sorting algorithms like merge sort. For each algorithm, it provides the steps, advantages, and disadvantages. It concludes with a complexity comparison table of typical sorting algorithms.

Uploaded by

dakc.cse
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)
31 views12 pages

Bwu - Bta - 22 - 416 - Subrata Dhara Bta

The document compares and analyzes different sorting algorithms. It discusses internal sorting algorithms like bubble sort, selection sort, quick sort, and insertion sort. It also covers external sorting algorithms like merge sort. For each algorithm, it provides the steps, advantages, and disadvantages. It concludes with a complexity comparison table of typical sorting algorithms.

Uploaded by

dakc.cse
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/ 12

BRAINWARE

UNIVERSITY
NAME : SUBRATA DHARA
CODE:BWU/BTA/22/416
SECTION:G GROUP:2
COURSE NAME :DESIGN AND ANALYSIS OF ALGORITHMS
COURSE CODE:-PCC-CSM402
SEMESTER:4
-:TOPIC:-

Comparative Analysis of Sorting


Algorithms
Sorting Algorithms
Sorting is a process of rearrangement a list of
elements to the correct order since handling the
elements in a certain order more efficient than
handling randomize elements. Sorting and
searching are among the most common
programming processes.
Need of sorting algorithms
Sorting algorithm is a method for reorganizing a large number of items into a specific order, such as
alphabetical, highest-to-lowest value or shortest-to-longest distance. Sorting algorithms take lists of
items as input data, perform specific operations on those lists and deliver ordered arrays as output.

The sorting techniques can be divided into two categories:


Internal Sort : In internal sorting, all the data to sort is stored in memory at all times while sorting is in
progress. e.g : bubble sort, quick sort, insertion sort, selection sort , etc.
External Sort : In external sorting data is stored outside memory (like on disk) and only loaded into memory
in small chunks. External sorting is usually applied in cases when data can’t fit into memory entirely. e.g :
merge sort , heap sort , etc.
Bubble Sort
The bubble sort works on the basis for given lists by swapping adjacent item or data in order, until the entire
lists of item or data are obtained in a sequence based upon their key values.

This takes the following steps as shown below:


Step 1: Consider the set of elements which can be of any data for the given lists.
Step 2: Swap first two data for the given lists adjacently using one by one pairs.
Step 3: Repeat the process for all the items or data in the given list.
Step 4: Return result for the same.

Advantages:
◾ It is one of the popular and easily implemented algorithms.
◾ Without using the extra storage, the items can be swapped easily.
Disadvantages:
◾ Does not deal with large number of items for the given lists.
Selection Sort
One of the simplest techniques used is the selection sort which works for the given lists of item
or data each time by selecting one item at a time and orders along with placing it in a correct
position in sequence.

This takes the following steps as shown below:


Step 1: First finds the smallest element for the given lists of item or data.
Step 2: Replaces that item or data in the first position.
Step 3: Next, again finds the smallest element among the lists.
Step 4: Get replaced in second position.
Step 5: Same procedure is followed unless the elements are sorted.
Step 6: Returns result.

Advantages:
◾ Before sorting the given lists, the ordering of data can be initialized.
◾ This works even for the smaller lists of items or data.
Disadvantages:
◾ For the large set of items or data this sorting results in poor efficiency.
◾ Compared to selection sort, the quick sort is most efficient.
Quick Sort
Quick sort as the name suggests helps in sorting list of items very quickly with less space and
is based upon the Divide and Conquer principle .

It takes the following steps :


Step 1: Pick the element from the given list and use as a pivot.
Step 2: Partition these elements into two sub-lists.
◾ Elements less than pivot.
◾ Elements greater than pivot.
Step 3: Quick sort two sub-lists.
Step 4: Repeat the process until the entire lists of item are sorted.
Step 5: Return result

Advantages:
◾ It can handle large items for the given lists.
◾ Does not require extra storage.
Disadvantages:
◾ The worst-case performance is same as bubble, selection and insertion sort.
◾ In case the given lists are already sorted, then bubble sort is more efficient compared to quick sort.
Insertion Sort
Insertion sort is an in-place sorting algorithm which is based on comparison. A data item that is
to be inserted in this sorted sub-list must find its appropriate place and then it is to be inserted.
Hence it is known as insertion sort.
It takes the following steps :
Step 1: If the first element is already sorted, Return 1;
Step 2: Take the next element
Step 3: Compare the element with all other elements in sorted sub-list
Step 4: Move all the elements in the sorted sub-list which is bigger than the Value to be sorted
Step 5: Insert the value
Step 6: Repeat until list is sorted

Advantages:
◾ Simple implementation
◾ Efficient for small data sets
Disadvantages:
◾ Less efficient for the list containing more elements
◾ It needs large number of element shifts
Merge Sort
Merge sort is a sorting technique which is based on the divide and conquers
technique. It first divides the given array into two equal parts and then joins them in a
sorted manner.

It takes the following steps :


Step 1: If the first element is already sorted, return 1.
Step 2: The list is divided recursively into two equal parts until it cannot be divided.
Step 3: Combine the smaller list of data items into the new list which has sorted
elements.

Advantages:
◾ Merge sort can be useful to files of any size.
◾ It is fast and stable
Disadvantages:
◾ Merge Sort takes more space when compared to other sorts.
◾ Merge sort is less efficient than other sort
Complexity Comparison between Typical sorting algorithms

The comparison of complexity between sorting algorithms are


listed in table,
References
 Ms Roopa K,Ms Reshma J(2018).A Comparative Study of Sorting and Searching
Algorithms . International Research Journal of Engineering and Technology.
 Adesina, Opeyemi. (2013) A Comparative Study of Sorting Algorithms . African Journal
of Computing & ICT. 6.199-206
THANK YOU

You might also like