1
 Introduction
 Sorting
 Selection Sort
 Bubble Sort
 Bubble Sorting:- Example
 Sorting and searching are fundamental
operations in computer science.
 Sorting refers to operation of arranging data
in some given order , such as increasing or
decreasing ,with numerical data or with
character data.
 Generally, collections of data are presented
in a sorted manner.
 Let A be a list of n elements A1,A2,……An in
Memory. Sorting A refers to the operation of
rearranging the contents of A so that they
are in increasing in order, so that
A1<A2<A3<…..<An
 Sorting = ordering.
 Sorted = ordered based on a particular way.
 Examples of Sorting:
 Words in a dictionary are sorted (and case
distinctions are ignored).
 Files in a directory are often listed in sorted
order.
 The index of a book is sorted (and case
distinctions are ignored).
 A relatively easy to understand algorithm
 Sorts an array in passes
 Each pass selects the next smallest element
 At the end of the pass, places it where it belongs
 Efficiency is O(n2
), hence called a quadratic
sort
 Performs:
 O(n2
) comparisons
 O(n) exchanges (swaps)
7
 Idea:
 Find the smallest element in the array
 Exchange it with the element in the first position
 Find the second smallest element and exchange it with
the element in the second position
 Continue until the array is sorted
 Disadvantage:
 Running time depends only slightly on the amount of
order in the file
35 65 30 60 20 scan 0-4, smallest
20
swap 35 and 20
20 65 30 60 35 scan 1-4, smallest
30
swap 65 and 30
20 30 65 60 35 scan 2-4, smallest
35
swap 65 and 35
20 30 35 60 65 scan 3-4, smallest
60
swap 60 and 60
20 30 35 60 65 done
1. for fill = 0 to n-2 do // steps 2-6 form a
pass
2. set posMin to fill
3. for next = fill+1 to n-1 do
4. if item at next < item at posMin
5. set posMin to next
6. Exchange item at posMin with one at
fill
 Let A be a list of n numbers. Sorting A refers to the
operation of rearranging the elements of A So they
are in increasing order ,So that,
A[1]<A[2]<A[3]<……….<A[N]
 Example :-
List is- 8,4,19,2,7,13,5,16
After Sorting :-
List is-2,4,5,7,8,13,16,19
 Suppose the following numbers are stored in
an array A:-
53,21,65,27,70,8,99,1.
Pass1-21,53,65,27,70,8,99,1
21,53,65,27,70,8,99,1
21,53,27,65,70,8,99,1
21,53,27,65,70,8,99,1
21,53,27,65,8,70,99,1
21,53,27,65,8,70,99,1
21,53,27,65,8,70,1,99
Pass2- 21,53,27,65,8,70,1,99
21,53,27,65,8,70,1,99
21,27,53,65,8,70,1,99
21,27,53,65,8,70,1,99
21,27,53,8,65,70,1,99
21,27,53,8,65,70,1,99
21,27,53,8,65,1,70,99
Pass3- 21,27,53,8,65,1,70,99
21,27,8,53,65,1,70,99
21,27,8,53,1,65,70,99
Pass4- 21,27,8,53,1,65,70,99
21,8,27,53,1,65,70,99
21,8,27,1,53,65,70,99
Pass5- 21,8,27,1,53,65,70,99
8,21,27,1,53,65,70,99
8,21,1,27,53,65,70,99
Pass6- 8,21,1,27,53,65,70,99
8,1,21,27,53,65,70,99
Pass7- 1,8,21,27,53,65,70,99
SORTED LIST IS:- 1,8,21,27,53,65,70,99
Sorting techniques

More Related Content

DOCX
Sorting
PPT
358 33 powerpoint-slides_14-sorting_chapter-14
PPT
Sorting Techniques
PPTX
Sorting Algorithms
PPTX
Different Sorting tecniques in Data Structure
PPTX
Different types of Shoring Algorithms with Animation
PPTX
Insertion sort
Sorting
358 33 powerpoint-slides_14-sorting_chapter-14
Sorting Techniques
Sorting Algorithms
Different Sorting tecniques in Data Structure
Different types of Shoring Algorithms with Animation
Insertion sort

What's hot (20)

PPTX
Sorting Algorithm
PPT
Data Structures- Part4 basic sorting algorithms
PDF
Sorting algorithm
PPTX
Sorting algorithms
PDF
Sorting
PPTX
Sorting algorithms
PDF
Data Structures & Algorithm design using C
PPTX
Insertion Sorting
PPTX
Searching & Sorting Algorithms
DOCX
Selection sort lab mannual
PPTX
Merge sort analysis and its real time applications
PPT
Sorting algorithums > Data Structures & Algorithums
PPT
3.9 external sorting
PPT
Sorting
PPSX
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
PDF
Sorting
PPTX
PDF
Analisys of Selection Sort and Bubble Sort
PDF
Sorting Algorithms
Sorting Algorithm
Data Structures- Part4 basic sorting algorithms
Sorting algorithm
Sorting algorithms
Sorting
Sorting algorithms
Data Structures & Algorithm design using C
Insertion Sorting
Searching & Sorting Algorithms
Selection sort lab mannual
Merge sort analysis and its real time applications
Sorting algorithums > Data Structures & Algorithums
3.9 external sorting
Sorting
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Sorting
Analisys of Selection Sort and Bubble Sort
Sorting Algorithms
Ad

Similar to Sorting techniques (20)

PPTX
Unit vii sorting
PPTX
Sorting
PPT
Chapter 4 ds
PDF
PPTX
searching in data structure.pptx
PPT
Sorting algorithms
PPT
Unit6 C
PPT
COMPUTER PROGRAMMING UNIT 1 Lecture 5
PPT
PDF
Sorting and Searching Techniques
DOC
Selection sort
PPTX
Lecture 13 data structures and algorithms
PPTX
Searching and Sorting algorithms and working
PPT
Counting sort(Non Comparison Sort)
PPT
Counting Sort Lowerbound
PPT
Data Structure (MC501)
PPT
lecture 10
PPTX
Sorting2
PPTX
Lec 03 - Sorting.pptx
PDF
Unit vii sorting
Sorting
Chapter 4 ds
searching in data structure.pptx
Sorting algorithms
Unit6 C
COMPUTER PROGRAMMING UNIT 1 Lecture 5
Sorting and Searching Techniques
Selection sort
Lecture 13 data structures and algorithms
Searching and Sorting algorithms and working
Counting sort(Non Comparison Sort)
Counting Sort Lowerbound
Data Structure (MC501)
lecture 10
Sorting2
Lec 03 - Sorting.pptx
Ad

More from Lovely Professional University (20)

PPTX
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
PPTX
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
PPTX
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
PPTX
Programme Management & Project Evaluation
PPTX
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
PPTX
Introduction to Software Project Management:
PDF
The HyperText Markup Language or HTML is the standard markup language
PPTX
PPTX
PPTX
Getting Input from User
PPTX
PPTX
Transaction Processing in DBMS.pptx
PPT
web_server_browser.ppt
PPTX
PPTX
Number System.pptx
PPT
Programming Language.ppt
PPTX
Information System.pptx
PPTX
Applications of Computer Science in Pharmacy-1.pptx
PPTX
Application of Computers in Pharmacy.pptx
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Programme Management & Project Evaluation
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Introduction to Software Project Management:
The HyperText Markup Language or HTML is the standard markup language
Getting Input from User
Transaction Processing in DBMS.pptx
web_server_browser.ppt
Number System.pptx
Programming Language.ppt
Information System.pptx
Applications of Computer Science in Pharmacy-1.pptx
Application of Computers in Pharmacy.pptx

Recently uploaded (20)

PPTX
Micro1New.ppt.pptx the main themes if micro
PPT
UNIT-I Machine Learning Essentials for 2nd years
PDF
Beginners-Guide-to-Artificial-Intelligence.pdf
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PDF
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
PDF
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
PPTX
Design ,Art Across Digital Realities and eXtended Reality
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
PDF
Present and Future of Systems Engineering: Air Combat Systems
PDF
SEH5E Unveiled: Enhancements and Key Takeaways for Certification Success
PPTX
Agentic Artificial Intelligence (Agentic AI).pptx
PPTX
Solar energy pdf of gitam songa hemant k
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PDF
Cryptography and Network Security-Module-I.pdf
PDF
Micro 4 New.ppt.pdf a servay of cells and microorganism
PPTX
CT Generations and Image Reconstruction methods
PPTX
chapter 1.pptx dotnet technology introduction
PDF
VSL-Strand-Post-tensioning-Systems-Technical-Catalogue_2019-01.pdf
PDF
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
Micro1New.ppt.pptx the main themes if micro
UNIT-I Machine Learning Essentials for 2nd years
Beginners-Guide-to-Artificial-Intelligence.pdf
20250617 - IR - Global Guide for HR - 51 pages.pdf
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
Design ,Art Across Digital Realities and eXtended Reality
Principles of operation, construction, theory, advantages and disadvantages, ...
Present and Future of Systems Engineering: Air Combat Systems
SEH5E Unveiled: Enhancements and Key Takeaways for Certification Success
Agentic Artificial Intelligence (Agentic AI).pptx
Solar energy pdf of gitam songa hemant k
Computer organization and architecuture Digital Notes....pdf
Computer System Architecture 3rd Edition-M Morris Mano.pdf
Cryptography and Network Security-Module-I.pdf
Micro 4 New.ppt.pdf a servay of cells and microorganism
CT Generations and Image Reconstruction methods
chapter 1.pptx dotnet technology introduction
VSL-Strand-Post-tensioning-Systems-Technical-Catalogue_2019-01.pdf
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf

Sorting techniques

  • 1. 1
  • 2.  Introduction  Sorting  Selection Sort  Bubble Sort  Bubble Sorting:- Example
  • 3.  Sorting and searching are fundamental operations in computer science.  Sorting refers to operation of arranging data in some given order , such as increasing or decreasing ,with numerical data or with character data.  Generally, collections of data are presented in a sorted manner.
  • 4.  Let A be a list of n elements A1,A2,……An in Memory. Sorting A refers to the operation of rearranging the contents of A so that they are in increasing in order, so that A1<A2<A3<…..<An
  • 5.  Sorting = ordering.  Sorted = ordered based on a particular way.  Examples of Sorting:  Words in a dictionary are sorted (and case distinctions are ignored).  Files in a directory are often listed in sorted order.  The index of a book is sorted (and case distinctions are ignored).
  • 6.  A relatively easy to understand algorithm  Sorts an array in passes  Each pass selects the next smallest element  At the end of the pass, places it where it belongs  Efficiency is O(n2 ), hence called a quadratic sort  Performs:  O(n2 ) comparisons  O(n) exchanges (swaps)
  • 7. 7  Idea:  Find the smallest element in the array  Exchange it with the element in the first position  Find the second smallest element and exchange it with the element in the second position  Continue until the array is sorted  Disadvantage:  Running time depends only slightly on the amount of order in the file
  • 8. 35 65 30 60 20 scan 0-4, smallest 20 swap 35 and 20 20 65 30 60 35 scan 1-4, smallest 30 swap 65 and 30 20 30 65 60 35 scan 2-4, smallest 35 swap 65 and 35 20 30 35 60 65 scan 3-4, smallest 60 swap 60 and 60 20 30 35 60 65 done
  • 9. 1. for fill = 0 to n-2 do // steps 2-6 form a pass 2. set posMin to fill 3. for next = fill+1 to n-1 do 4. if item at next < item at posMin 5. set posMin to next 6. Exchange item at posMin with one at fill
  • 10.  Let A be a list of n numbers. Sorting A refers to the operation of rearranging the elements of A So they are in increasing order ,So that, A[1]<A[2]<A[3]<……….<A[N]  Example :- List is- 8,4,19,2,7,13,5,16 After Sorting :- List is-2,4,5,7,8,13,16,19
  • 11.  Suppose the following numbers are stored in an array A:- 53,21,65,27,70,8,99,1. Pass1-21,53,65,27,70,8,99,1 21,53,65,27,70,8,99,1 21,53,27,65,70,8,99,1 21,53,27,65,70,8,99,1 21,53,27,65,8,70,99,1 21,53,27,65,8,70,99,1 21,53,27,65,8,70,1,99
  • 13. Pass4- 21,27,8,53,1,65,70,99 21,8,27,53,1,65,70,99 21,8,27,1,53,65,70,99 Pass5- 21,8,27,1,53,65,70,99 8,21,27,1,53,65,70,99 8,21,1,27,53,65,70,99 Pass6- 8,21,1,27,53,65,70,99 8,1,21,27,53,65,70,99 Pass7- 1,8,21,27,53,65,70,99 SORTED LIST IS:- 1,8,21,27,53,65,70,99