SlideShare a Scribd company logo
Sorting and Its Types
Sorting and Its Types
Sorting
And Its
Types
SORTING
Sorting refers to operations of
arranging a set of data in a given
order.
10 20 30 40 50 60
30 10 60 20 50 40 Unsorted List
Sorted List
BASIC TYPES :
Internal Sorting:
If all the data to be sorted can be
adjusted in main memory then it is
called as Internal Sorting.
External Sorting:
If data to be stored is large and aquires
external memory then the type is called
as External Sorting.
METHODS OF SORTING:
Bubble Sort
Selection Sort
Insertion Sort
BUBBLE SORT
ALGORITHM
Bubble Sort:
Algorithm of bubble sort includes two steps
repeated until the list is sorted.
 Compare adjacent elements, if the
element on right side is smaller then
swap their positions.
 Compare first element, second element
and so on on completion of Pass 1 the
largest element is at last position.
Pass 1:
50 10 20 30 40
50 10 20 30 40
10 50 20 30 40
10 20 50 30 40
10 20 30 50 40
10 20 30 40 50
0,1
1,2
2,3
3,4
Number Of Passes = Max – 1 = 5 – 1 = 4
SORTED LIST
SELECTION SORT
ALGORITHM
Selection Sort:
Here in selection sort the algorithm depends on the
zeroth element majorly.
 The Zeroth element is compared with the first
element and if the element at right is found smaller
then their positions are swapped or exchanged.
 The same procedure is carried with all elements of
the list resulting into a fully sorted list.
23 15 29 11 1
23 15 29 11 1
Pass
1:
Number Of Passes = Max – 1 = 5 – 1 = 4
15 23 29 11 1
15 23 29 11 1
11 23 29 15 1
1 23 29 15 11
0,1
0,2
0,3
0,4
1 23 29 15 11
Pass 2:
1 29 23 15 11
1 15 23 29 11
1 11 23 29 15
1,2
1,3
1,4
1 11 23 29 15
Pass 3:
1 11 23 29 15
1 11 15 29 23
2,3
2,4
Pass 4:
1 11 15 29 23
1 11 15 23 29
1 11 15 23 29 Sorted List
3,4
INSERTION SORT
Mathematical applications : in the search for
greater value, or the smallest value. In
many other applications.
This method is effective when dealing
with small numbers .
ALGORITHM
Insertion Sort
In insertion sort the elements are compared
and inserted to respective index place.
 It starts with comparision of 1st and 0th
element in pass 1.
 In pass 2 the second element is compared
with the 1st and 0th element.
 Doing so with all the elements in the list
appropriate element is inserted by shifting
elements on right.
75 57 25 19 4
Pass 1: Number Of Passes = Max – 1 = 5 – 1 = 4
57 75 25 19 4
75 57 25 19 4 0,1
Pass 2:
57 75 25 19 4
25 57 75 19 4
0,2
Pass 3:
25 57 75 19 4
19 25 57 75 4
0,3
4 19 25 57 75
Pass 4:
19 25 57 75 4 0,4
Thank You…!

More Related Content

PPTX
sorting and its types
PPTX
Selection sort 1
PPT
Selection sort
PPTX
Selection sort algorithm presentation, selection sort example using power point
PPTX
PPT
lecture 9
PPTX
Selection sorting
PPTX
Presentation on the topic selection sort
sorting and its types
Selection sort 1
Selection sort
Selection sort algorithm presentation, selection sort example using power point
lecture 9
Selection sorting
Presentation on the topic selection sort

What's hot (20)

PPT
SEARCHING AND SORTING ALGORITHMS
PPTX
Relational algebra
PPTX
Selection and insertion sort
PPTX
Selection and insertion sort
PPTX
Selection sort
PPTX
Merge sort analysis and its real time applications
PPT
Selection Sort - Vipin Ramola
PPTX
Data Structures and Algorithms
PPT
Selection sort
PPTX
Sorting (Bubble,Merge,Selection sort)
PPTX
Selection sort and insertion sort
PPTX
Presentation Of Analysis
PDF
Sorting (introduction)
PPSX
Logarithmic function, equation and inequality
PPT
Solving linear equations in two
PPTX
PDF
linear search and binary search
PDF
Module 6 Mastery
PPT
Chapter 11 - Sorting and Searching
SEARCHING AND SORTING ALGORITHMS
Relational algebra
Selection and insertion sort
Selection and insertion sort
Selection sort
Merge sort analysis and its real time applications
Selection Sort - Vipin Ramola
Data Structures and Algorithms
Selection sort
Sorting (Bubble,Merge,Selection sort)
Selection sort and insertion sort
Presentation Of Analysis
Sorting (introduction)
Logarithmic function, equation and inequality
Solving linear equations in two
linear search and binary search
Module 6 Mastery
Chapter 11 - Sorting and Searching
Ad

Similar to Sorting and Its Types (20)

PPTX
Data structure using c module 3
PPTX
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
PPTX
366 it elective 4 (analysis of algoritm)
PPTX
AJisthewewrtyuiojhghfdfsgvhjhklopi87ytrytfghjk
PPTX
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
PDF
advanced searching and sorting.pdf
PDF
Unit v data structure-converted
PPTX
sorting and searching.pptx
PPTX
Sorting method data structure
PPTX
Searching and Sorting algorithms and working
PPTX
Data structure.pptx
PPTX
Sorting Data structure And Algorithm.pptx
PPT
Lecture_4 (Sorting Algorithms) before mids - Copy.ppt
PPTX
DS - Unit 2 FINAL (2).pptx
PPTX
Data Structures_ Sorting & Searching
PPT
Sorting algorithms
PPTX
Sorting
PPTX
Lecture of algorithms and problem solving
PPTX
Bubble sort, Selection sort SORTING .pptx
PPTX
Chapter 3 - Data Structure and Algorithms.pptx
Data structure using c module 3
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
366 it elective 4 (analysis of algoritm)
AJisthewewrtyuiojhghfdfsgvhjhklopi87ytrytfghjk
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
advanced searching and sorting.pdf
Unit v data structure-converted
sorting and searching.pptx
Sorting method data structure
Searching and Sorting algorithms and working
Data structure.pptx
Sorting Data structure And Algorithm.pptx
Lecture_4 (Sorting Algorithms) before mids - Copy.ppt
DS - Unit 2 FINAL (2).pptx
Data Structures_ Sorting & Searching
Sorting algorithms
Sorting
Lecture of algorithms and problem solving
Bubble sort, Selection sort SORTING .pptx
Chapter 3 - Data Structure and Algorithms.pptx
Ad

More from amberkhan59 (7)

PPT
Semantic Web
PPT
Semantic Web
PPTX
Lec#04
PPTX
Lec#03
PPTX
Lec#02
PPTX
Lecture#1
PPTX
Ict lec#9
Semantic Web
Semantic Web
Lec#04
Lec#03
Lec#02
Lecture#1
Ict lec#9

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Pre independence Education in Inndia.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Institutional Correction lecture only . . .
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Complications of Minimal Access Surgery at WLH
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Lesson notes of climatology university.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pre independence Education in Inndia.pdf
human mycosis Human fungal infections are called human mycosis..pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Insiders guide to clinical Medicine.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Institutional Correction lecture only . . .
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Complications of Minimal Access Surgery at WLH
Module 4: Burden of Disease Tutorial Slides S2 2025
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Lesson notes of climatology university.

Sorting and Its Types

  • 4. SORTING Sorting refers to operations of arranging a set of data in a given order. 10 20 30 40 50 60 30 10 60 20 50 40 Unsorted List Sorted List
  • 5. BASIC TYPES : Internal Sorting: If all the data to be sorted can be adjusted in main memory then it is called as Internal Sorting. External Sorting: If data to be stored is large and aquires external memory then the type is called as External Sorting.
  • 6. METHODS OF SORTING: Bubble Sort Selection Sort Insertion Sort
  • 8. ALGORITHM Bubble Sort: Algorithm of bubble sort includes two steps repeated until the list is sorted.  Compare adjacent elements, if the element on right side is smaller then swap their positions.  Compare first element, second element and so on on completion of Pass 1 the largest element is at last position.
  • 9. Pass 1: 50 10 20 30 40 50 10 20 30 40 10 50 20 30 40 10 20 50 30 40 10 20 30 50 40 10 20 30 40 50 0,1 1,2 2,3 3,4 Number Of Passes = Max – 1 = 5 – 1 = 4 SORTED LIST
  • 11. ALGORITHM Selection Sort: Here in selection sort the algorithm depends on the zeroth element majorly.  The Zeroth element is compared with the first element and if the element at right is found smaller then their positions are swapped or exchanged.  The same procedure is carried with all elements of the list resulting into a fully sorted list.
  • 12. 23 15 29 11 1 23 15 29 11 1 Pass 1: Number Of Passes = Max – 1 = 5 – 1 = 4 15 23 29 11 1 15 23 29 11 1 11 23 29 15 1 1 23 29 15 11 0,1 0,2 0,3 0,4
  • 13. 1 23 29 15 11 Pass 2: 1 29 23 15 11 1 15 23 29 11 1 11 23 29 15 1,2 1,3 1,4
  • 14. 1 11 23 29 15 Pass 3: 1 11 23 29 15 1 11 15 29 23 2,3 2,4
  • 15. Pass 4: 1 11 15 29 23 1 11 15 23 29 1 11 15 23 29 Sorted List 3,4
  • 17. Mathematical applications : in the search for greater value, or the smallest value. In many other applications. This method is effective when dealing with small numbers .
  • 18. ALGORITHM Insertion Sort In insertion sort the elements are compared and inserted to respective index place.  It starts with comparision of 1st and 0th element in pass 1.  In pass 2 the second element is compared with the 1st and 0th element.  Doing so with all the elements in the list appropriate element is inserted by shifting elements on right.
  • 19. 75 57 25 19 4 Pass 1: Number Of Passes = Max – 1 = 5 – 1 = 4 57 75 25 19 4 75 57 25 19 4 0,1
  • 20. Pass 2: 57 75 25 19 4 25 57 75 19 4 0,2
  • 21. Pass 3: 25 57 75 19 4 19 25 57 75 4 0,3
  • 22. 4 19 25 57 75 Pass 4: 19 25 57 75 4 0,4