SlideShare a Scribd company logo
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

What's hot

SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Joshi Vinay
 
Selection and insertion sort
Selection and insertion sortSelection and insertion sort
Selection and insertion sort
Ann Tugade
 
Selection and insertion sort
Selection and insertion sortSelection and insertion sort
Selection and insertion sort
Ann Tugade
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
yazad dumasia
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
Dipayan Sarkar
 
Selection sort
Selection sortSelection sort
Selection sort
amna izzat
 
Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)
oDesk
 
Selection sort and insertion sort
Selection sort and insertion sortSelection sort and insertion sort
Selection sort and insertion sort
May Ann Mendoza
 
Presentation Of Analysis
Presentation Of Analysis  Presentation Of Analysis
Presentation Of Analysis
Mahnoor Altaf Khan Afridi
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)Arvind Devaraj
 
Logarithmic function, equation and inequality
Logarithmic function, equation and inequalityLogarithmic function, equation and inequality
Logarithmic function, equation and inequality
Felina Victoria
 
Solving linear equations in two
Solving linear equations in twoSolving linear equations in two
Solving linear equations in twomstf mstf
 
Join
JoinJoin
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
Module 6 Mastery
Module 6 MasteryModule 6 Mastery
Module 6 Mastery
bigerblue
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 

What's hot (20)

SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Selection and insertion sort
Selection and insertion sortSelection and insertion sort
Selection and insertion sort
 
Selection and insertion sort
Selection and insertion sortSelection and insertion sort
Selection and insertion sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
Sorting
SortingSorting
Sorting
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
 
Data Structures and Algorithms
Data Structures and AlgorithmsData Structures and Algorithms
Data Structures and Algorithms
 
Selection sort
Selection sortSelection sort
Selection sort
 
Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)
 
Selection sort and insertion sort
Selection sort and insertion sortSelection sort and insertion sort
Selection sort and insertion sort
 
Presentation Of Analysis
Presentation Of Analysis  Presentation Of Analysis
Presentation Of Analysis
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)
 
Logarithmic function, equation and inequality
Logarithmic function, equation and inequalityLogarithmic function, equation and inequality
Logarithmic function, equation and inequality
 
Solving linear equations in two
Solving linear equations in twoSolving linear equations in two
Solving linear equations in two
 
Join
JoinJoin
Join
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Module 6 Mastery
Module 6 MasteryModule 6 Mastery
Module 6 Mastery
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 

Similar to Sorting and Its Types

Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3
smruti sarangi
 
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
DS PPT - ( 1 )SORTING lgoritham techniques with bast exampleDS PPT - ( 1 )SORTING lgoritham techniques with bast example
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
Vivek487417
 
366 it elective 4 (analysis of algoritm)
366 it elective 4 (analysis of algoritm)366 it elective 4 (analysis of algoritm)
366 it elective 4 (analysis of algoritm)
Neil Soliven
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
haramaya university
 
sorting and searching.pptx
sorting and searching.pptxsorting and searching.pptx
sorting and searching.pptx
ParagAhir1
 
Sorting method data structure
Sorting method data structureSorting method data structure
Sorting method data structure
sunilchute1
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 
Sorting Data structure And Algorithm.pptx
Sorting Data structure And Algorithm.pptxSorting Data structure And Algorithm.pptx
Sorting Data structure And Algorithm.pptx
subhanalichand514
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & Searching
ThenmozhiK5
 
DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
prakashvs7
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
CHANDAN KUMAR
 
Sorting
SortingSorting
Sorting
Saharamily
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
Kalpana Mohan
 
Sorting
SortingSorting
Sorting
SortingSorting
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
nikshaikh786
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
Mohammed472103
 
Algo PPT.pdf
Algo PPT.pdfAlgo PPT.pdf
Algo PPT.pdf
sheraz7288
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
ssuserd602fd
 

Similar to Sorting and Its Types (20)

Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3
 
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
DS PPT - ( 1 )SORTING lgoritham techniques with bast exampleDS PPT - ( 1 )SORTING lgoritham techniques with bast example
DS PPT - ( 1 )SORTING lgoritham techniques with bast example
 
366 it elective 4 (analysis of algoritm)
366 it elective 4 (analysis of algoritm)366 it elective 4 (analysis of algoritm)
366 it elective 4 (analysis of algoritm)
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
 
Unit v data structure-converted
Unit  v data structure-convertedUnit  v data structure-converted
Unit v data structure-converted
 
sorting and searching.pptx
sorting and searching.pptxsorting and searching.pptx
sorting and searching.pptx
 
Sorting method data structure
Sorting method data structureSorting method data structure
Sorting method data structure
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Sorting Data structure And Algorithm.pptx
Sorting Data structure And Algorithm.pptxSorting Data structure And Algorithm.pptx
Sorting Data structure And Algorithm.pptx
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & Searching
 
DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Sorting
SortingSorting
Sorting
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
 
Sorting
SortingSorting
Sorting
 
Sorting
SortingSorting
Sorting
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
 
Algo PPT.pdf
Algo PPT.pdfAlgo PPT.pdf
Algo PPT.pdf
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
 

More from amberkhan59

Semantic Web
Semantic WebSemantic Web
Semantic Web
amberkhan59
 
Semantic Web
Semantic WebSemantic Web
Semantic Web
amberkhan59
 
Lec#04
Lec#04Lec#04
Lec#04
amberkhan59
 
Lec#03
Lec#03Lec#03
Lec#03
amberkhan59
 
Lec#02
Lec#02Lec#02
Lec#02
amberkhan59
 
Lecture#1
Lecture#1Lecture#1
Lecture#1
amberkhan59
 
Ict lec#9
Ict lec#9Ict lec#9
Ict lec#9
amberkhan59
 

More from amberkhan59 (7)

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

Recently uploaded

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 

Recently uploaded (20)

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 

Sorting and Its Types

  • 1.
  • 2.
  • 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