0% found this document useful (0 votes)
39 views9 pages

Analysis & Design of Algorithms: Introduction To Sorting

This document provides an introduction to sorting algorithms. It discusses how sorting is an important algorithmic problem that puts elements in a certain order, most commonly numerical or alphabetical. The document outlines factors to consider when deciding which sorting algorithm to use, such as the number of elements, presence of duplicates, and available resources. It also classifies sorting algorithms based on computational complexity, memory usage, recursion, and stability. Finally, it lists several common sorting algorithms that will be covered, including selection sort, bubble sort, insertion sort, and merge sort.

Uploaded by

tempuser26
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)
39 views9 pages

Analysis & Design of Algorithms: Introduction To Sorting

This document provides an introduction to sorting algorithms. It discusses how sorting is an important algorithmic problem that puts elements in a certain order, most commonly numerical or alphabetical. The document outlines factors to consider when deciding which sorting algorithm to use, such as the number of elements, presence of duplicates, and available resources. It also classifies sorting algorithms based on computational complexity, memory usage, recursion, and stability. Finally, it lists several common sorting algorithms that will be covered, including selection sort, bubble sort, insertion sort, and merge sort.

Uploaded by

tempuser26
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/ 9

Analysis & Design of Algorithms

I nt roduc t i on to
Sorting • Prepared by:-

Sagar Virani
Assistant Professor

Computer Engineering
Department
VVP Engineering College
Introduction to Sorting
• Sorting is the fundamental algorithmic problem in mathematics and
computer science.
• It puts elements in a certain order.
• The most common used orders are numerical and lexicographical
(alphabetical) order.
Introduction to Sorting
• Efficient sorting is important to optimize the use of other algorithms,
as it is the first step in most of them.
• There are many sorting algorithms but knowing which one to use
depends on the specific problem at hand.
Introduction to Sorting
Factors that help decide the sort to use are:
• How many elements needed to sort?
 Will there be duplicate elements in the data?
 If yes, does their order need to be maintained after sorting?
• What do we know about the distribution of elements?
 Partially sorted
 Totally random
 Almost sorted
• What resources are available for executing sorts?
 More memory
 More processors
Introduction to Sorting
Sorting algorithms are often classified using different metrics:
• Computational complexity
 Based on worst, average and best-case behavior
 Acceptable behavior – O(n lgn)
 Unacceptable behavior – O(n2)
• Memory usage
 In-place
 Not in-place
• Recursion
 Recursive
 Non-recursive
• Stability
 Stable
 Not stable
Introduction to Sorting
In-place sorting 
• In-place means that the algorithm does not use extra space for manipulating the

input but may require a small though non-constant extra space for its operation.

• Usually, this space is O(log n), though sometimes anything in o(n) (Smaller

than linear) is allowed.

Input List Auxiliary Memory

9 2 7 5 2 4 3 6
Introduction to Sorting
Stable sorting 
• Stable sorting algorithms maintain the relative order of records with equal keys

(i.e., values).

• That is, a sorting algorithm is stable if whenever there are two records R and S

with the same key and with R appearing before S in the original list, R will

appear before S in the sorted list.


Input List Sorted List

9 2 7 5 2 4 3 6 2 2 3 4 5 6 7 9

R S R S
Sorting Algorithms
Covered in the Syllabus:
• Selection Sort
• Bubble Sort
• Insertion Sort
• Shell Sort
• Heap Sort
• Counting Sort
• Radix Sort
• Bucket Sort
• Merge Sort
• Quick Sort
Any Questions?

You might also like