SlideShare a Scribd company logo
1 of 24
Algorithm And
Sorting
Aung Myint Tun
Presented by
CONTENTS
1. What is Algorithm?
2. Usage of Algorithm.
3. Example of Algorithm with flow chart diagram.
4. What is sorting?
5. One of sorting algorithm(Selection Sort)
Previously…
A program MUST be systematically and
properly designed before coding begins.
This design process results in the
construction of an ALGORITHM
An algorithm is a precise set of instructions that you
follow to solve a problem or complete a task.
We can say that algorithm is:
● A step‐by‐step problem‐solving procedure.
● A sequence of instruction that tell how to solve
a particular problem.
● A set of instruction for solving a problem,
especially on a computer.
● A computable set of steps to achieve a desired
result.
However, most agree that algorithm has something
to do with defining generalized processes to get
“output” from the “input”.
What is an
Algorithm?
Recipes
When you follow a recipe, you follow instructions to complete a task.
The instructions are a step-by-step procedure that need to be followed for your recipe to be
successful.
From Algorithm to Program
● Both are sets of instructions on how to do a task;
● Algorithm:
○ talking to humans, easy to understand
○ in plain (English) language
● Program:
○ talking to computer (compiler)
○ can be regarded as a “formal expression” of an algorithm
From Algorithm to Program
PROGRAM
ALGORITHM
a sequence of instructions
describing how to do a task (or
process)
a set of instructions which
are commands to
computers to perform
specific operations on data
Algorithms in Technology
You use an algorithm to tell a computer what to do.
Everything you can do on a computer is able to happen because an
algorithm has been written for it.
Clicking a mouse, opening a word document and playing a game are
all examples of things that have algorithms.
Digital devices all follow algorithms in order for them to work.
Flowchart Symbol and Description
Name Symbol Description
Lozenge Indicates the starting or ending of flowchart
(start / stop : terminal )
Connector Used to connect break in the flowchart
Parallelelogram Use for input and output operation (data)
Rectangle Indicates any interval operation (process)
Diamond Use for asking questions that can have
either TRUE of FALSE / YES or NO
(decision / selection)
Module Sub solution to solve a part of entire problem
Control flow Shows flow direction
Flowchart Example
Design an algorithm to find the area of a
rectangle
The formulas: area = length * width
Input Process Output
Input variable:
length
width
Processing item:
area
Formula:
area = length x width
Step / Solution algorithm:
get input
calculate area
display output
Output:
area
Start
length, width
calculate area
area
End
Pseudo Code Example
Start
Read length
Read width
Calculate area of a rectangle
Display area of a rectangle
End
Design an algorithm to find the area of a rectangle
The formulas: area = length * width
Input Process Output
Input
variable:
length
width
Processing item:
area
Formula:
area = length x width
Step / Solution
algorithm:
get input
calculate area
display output
Output:
area
Start
Prompt the user to enter a length of a rectangle
Prompt the user to enter a width of a rectangle
Calculate the area of a rectangle
Display the area of a rectangle
End
Start
Input length
Input width
Calculate area of a rectangle
Output area of a rectangle
End
OR
OR
What is
sorting?
Sorting
● Sorting means arranging the elements of an array so that they are placed in
some relevant order which may be either ascending or descending.
● Can be used as a first step for searching the data.
● That is, if A is an array, then the elements of A are arranged in a sorted order
(ascending order) in such a way that A[0] < A[1] < A[2] < … < A[N].
● The practical considerations for different sorting techniques would be:
○ Number of sort key comparisons that will be performed.
○ Number of times the records in the list will be moved.
○ Best, average and worst case performance.
○ Stability of the sorting algorithm where stability means that equivalent
elements or records retain their relative positions even after sorting is
Bubble Sort
Selection Sort Insertion Sort
Types of sorting
Quick Sort Merge Sort
• Selection sort is one of the easiest approaches to sorting.
• It is inspired from the way in which we sort things out in day to
day life.
• It is an in-place sorting algorithm because it uses no auxiliary
data structures while sorting.
Selection Sort
How Selection Sort Work?
Selection Sort
● Suppose the name of the array is A and it has four
elements with the following values:
4 19 1 3
 To sort this array in ascending order, n-1,
i.e. three iterations will be required.
Selection Sort
● Iteration-1
The array is scanned starting from the first to the last element and the element that has the
smallest value is selected. The smallest value is 1 at location 3. The address of element that
has the smallest value is noted and the selected value is interchanged with the first element
i.e.
A[1] and A[3] are swapped
4 19 1 3
1 19 4 3
Selection Sort
● Iteration-2
The array is scanned starting from the second to the last element and the element that has
the smallest value is selected. The smallest value is 3 at location 4. The address of element
that has the smallest value is noted. The selected value is interchanged with the second
element i.e.
A[2] and A[4] are swapped
1 19 4 3
1 3 4 19
Selection Sort
● Iteration-3
The array is scanned starting from the third to the last element and the element that has the
smallest value is selected. The smallest value is 4 at location 3. The address of element that
has the smallest value is noted. The selected value is interchanged with the third element
i.e.
A[3] and A[3] are swapped
1 3 4 19
1 3 4 19
SELECTION SORT
Thank You
Presented By Aung Myint Tun
Do You Have Any Question!

More Related Content

Similar to Algorithm By AMT.pptx

Data Structures in C
Data Structures in CData Structures in C
Data Structures in CJabs6
 
Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfAkashSingh625550
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1seshagiri rao
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introductionssuseraf8b2f
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
Unit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.pptUnit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.pptHODElex
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptxKiran Babar
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharpMicheal Ogundero
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing conceptsLJ Projects
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing conceptsLJ Projects
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortIRJET Journal
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.NandiniSidana
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingMvenkatarao
 

Similar to Algorithm By AMT.pptx (20)

Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdf
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introduction
 
9 Arrays
9 Arrays9 Arrays
9 Arrays
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Unit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.pptUnit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.ppt
 
Sorting
SortingSorting
Sorting
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptx
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharp
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining Sort
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Algorithm Design and Analysis
Algorithm Design and AnalysisAlgorithm Design and Analysis
Algorithm Design and Analysis
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
 
Chapter3.pptx
Chapter3.pptxChapter3.pptx
Chapter3.pptx
 

Recently uploaded

Editing progress 20th march.docxxxxxxxxx
Editing progress 20th march.docxxxxxxxxxEditing progress 20th march.docxxxxxxxxx
Editing progress 20th march.docxxxxxxxxxMollyBrown86
 
SME IPO and sme ipo listing consultants .pptx
SME IPO and sme ipo listing consultants .pptxSME IPO and sme ipo listing consultants .pptx
SME IPO and sme ipo listing consultants .pptxindia IPO
 
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service Available
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service AvailableCall Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service Available
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service AvailableSheetaleventcompany
 
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts PodanurTop Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanurdharasingh5698
 
Nicola Mining Inc. Corporate Presentation May 2024
Nicola Mining Inc. Corporate Presentation May 2024Nicola Mining Inc. Corporate Presentation May 2024
Nicola Mining Inc. Corporate Presentation May 2024nicola_mining
 
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escortsindian call girls near you
 
slideshare Call girls Noida Escorts 9999965857 henakhan
slideshare Call girls Noida Escorts 9999965857 henakhanslideshare Call girls Noida Escorts 9999965857 henakhan
slideshare Call girls Noida Escorts 9999965857 henakhanhanshkumar9870
 
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
Corporate Presentation Probe May 2024.pdf
Corporate Presentation Probe May 2024.pdfCorporate Presentation Probe May 2024.pdf
Corporate Presentation Probe May 2024.pdfProbe Gold
 
Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024TeckResourcesLtd
 
B2 Interpret the brief.docxccccccccccccccc
B2 Interpret the brief.docxcccccccccccccccB2 Interpret the brief.docxccccccccccccccc
B2 Interpret the brief.docxcccccccccccccccMollyBrown86
 
Vijayawada ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready F...
Vijayawada ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready F...Vijayawada ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready F...
Vijayawada ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready F...tanu pandey
 

Recently uploaded (20)

Editing progress 20th march.docxxxxxxxxx
Editing progress 20th march.docxxxxxxxxxEditing progress 20th march.docxxxxxxxxx
Editing progress 20th march.docxxxxxxxxx
 
Call Girls 🫤 Hauz Khas ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
Call Girls 🫤 Hauz Khas ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOYCall Girls 🫤 Hauz Khas ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOY
Call Girls 🫤 Hauz Khas ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
 
SME IPO and sme ipo listing consultants .pptx
SME IPO and sme ipo listing consultants .pptxSME IPO and sme ipo listing consultants .pptx
SME IPO and sme ipo listing consultants .pptx
 
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service Available
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service AvailableCall Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service Available
Call Girls Chandigarh Just Call 8868886958 Top Class Call Girl Service Available
 
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi : 9999 Cash Pa...
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi  : 9999 Cash Pa...(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi  : 9999 Cash Pa...
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi : 9999 Cash Pa...
 
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts PodanurTop Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
 
Nicola Mining Inc. Corporate Presentation May 2024
Nicola Mining Inc. Corporate Presentation May 2024Nicola Mining Inc. Corporate Presentation May 2024
Nicola Mining Inc. Corporate Presentation May 2024
 
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
 
Vip Call Girls Vasant Kunj ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Vasant Kunj ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Vasant Kunj ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Vasant Kunj ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
slideshare Call girls Noida Escorts 9999965857 henakhan
slideshare Call girls Noida Escorts 9999965857 henakhanslideshare Call girls Noida Escorts 9999965857 henakhan
slideshare Call girls Noida Escorts 9999965857 henakhan
 
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Udyog Vihar Gurgaon >༒8448380779 Escort Service
 
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Goregaon Escorts With Room Vashi Call Girls 💃 9004004663
 
Corporate Presentation Probe May 2024.pdf
Corporate Presentation Probe May 2024.pdfCorporate Presentation Probe May 2024.pdf
Corporate Presentation Probe May 2024.pdf
 
Vip Call Girls South Ex ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls South Ex ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls South Ex ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls South Ex ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024
 
Sensual Moments: +91 9999965857 Independent Call Girls Noida Delhi {{ Monika}...
Sensual Moments: +91 9999965857 Independent Call Girls Noida Delhi {{ Monika}...Sensual Moments: +91 9999965857 Independent Call Girls Noida Delhi {{ Monika}...
Sensual Moments: +91 9999965857 Independent Call Girls Noida Delhi {{ Monika}...
 
B2 Interpret the brief.docxccccccccccccccc
B2 Interpret the brief.docxcccccccccccccccB2 Interpret the brief.docxccccccccccccccc
B2 Interpret the brief.docxccccccccccccccc
 
young call girls in Mahavir Nagar 🔝 9953056974 🔝 Delhi escort Service
young call girls in Mahavir Nagar 🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Mahavir Nagar 🔝 9953056974 🔝 Delhi escort Service
young call girls in Mahavir Nagar 🔝 9953056974 🔝 Delhi escort Service
 
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Vijayawada ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready F...
Vijayawada ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready F...Vijayawada ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready F...
Vijayawada ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready F...
 

Algorithm By AMT.pptx

  • 2. CONTENTS 1. What is Algorithm? 2. Usage of Algorithm. 3. Example of Algorithm with flow chart diagram. 4. What is sorting? 5. One of sorting algorithm(Selection Sort)
  • 3. Previously… A program MUST be systematically and properly designed before coding begins. This design process results in the construction of an ALGORITHM
  • 4. An algorithm is a precise set of instructions that you follow to solve a problem or complete a task. We can say that algorithm is: ● A step‐by‐step problem‐solving procedure. ● A sequence of instruction that tell how to solve a particular problem. ● A set of instruction for solving a problem, especially on a computer. ● A computable set of steps to achieve a desired result. However, most agree that algorithm has something to do with defining generalized processes to get “output” from the “input”. What is an Algorithm?
  • 5. Recipes When you follow a recipe, you follow instructions to complete a task. The instructions are a step-by-step procedure that need to be followed for your recipe to be successful.
  • 6. From Algorithm to Program ● Both are sets of instructions on how to do a task; ● Algorithm: ○ talking to humans, easy to understand ○ in plain (English) language ● Program: ○ talking to computer (compiler) ○ can be regarded as a “formal expression” of an algorithm
  • 7. From Algorithm to Program PROGRAM ALGORITHM a sequence of instructions describing how to do a task (or process) a set of instructions which are commands to computers to perform specific operations on data
  • 8. Algorithms in Technology You use an algorithm to tell a computer what to do. Everything you can do on a computer is able to happen because an algorithm has been written for it. Clicking a mouse, opening a word document and playing a game are all examples of things that have algorithms. Digital devices all follow algorithms in order for them to work.
  • 9. Flowchart Symbol and Description Name Symbol Description Lozenge Indicates the starting or ending of flowchart (start / stop : terminal ) Connector Used to connect break in the flowchart Parallelelogram Use for input and output operation (data) Rectangle Indicates any interval operation (process) Diamond Use for asking questions that can have either TRUE of FALSE / YES or NO (decision / selection) Module Sub solution to solve a part of entire problem Control flow Shows flow direction
  • 10. Flowchart Example Design an algorithm to find the area of a rectangle The formulas: area = length * width Input Process Output Input variable: length width Processing item: area Formula: area = length x width Step / Solution algorithm: get input calculate area display output Output: area Start length, width calculate area area End
  • 11. Pseudo Code Example Start Read length Read width Calculate area of a rectangle Display area of a rectangle End Design an algorithm to find the area of a rectangle The formulas: area = length * width Input Process Output Input variable: length width Processing item: area Formula: area = length x width Step / Solution algorithm: get input calculate area display output Output: area Start Prompt the user to enter a length of a rectangle Prompt the user to enter a width of a rectangle Calculate the area of a rectangle Display the area of a rectangle End Start Input length Input width Calculate area of a rectangle Output area of a rectangle End OR OR
  • 13. Sorting ● Sorting means arranging the elements of an array so that they are placed in some relevant order which may be either ascending or descending. ● Can be used as a first step for searching the data. ● That is, if A is an array, then the elements of A are arranged in a sorted order (ascending order) in such a way that A[0] < A[1] < A[2] < … < A[N]. ● The practical considerations for different sorting techniques would be: ○ Number of sort key comparisons that will be performed. ○ Number of times the records in the list will be moved. ○ Best, average and worst case performance. ○ Stability of the sorting algorithm where stability means that equivalent elements or records retain their relative positions even after sorting is
  • 14. Bubble Sort Selection Sort Insertion Sort Types of sorting Quick Sort Merge Sort
  • 15. • Selection sort is one of the easiest approaches to sorting. • It is inspired from the way in which we sort things out in day to day life. • It is an in-place sorting algorithm because it uses no auxiliary data structures while sorting. Selection Sort
  • 16.
  • 18. Selection Sort ● Suppose the name of the array is A and it has four elements with the following values: 4 19 1 3  To sort this array in ascending order, n-1, i.e. three iterations will be required.
  • 19. Selection Sort ● Iteration-1 The array is scanned starting from the first to the last element and the element that has the smallest value is selected. The smallest value is 1 at location 3. The address of element that has the smallest value is noted and the selected value is interchanged with the first element i.e. A[1] and A[3] are swapped 4 19 1 3 1 19 4 3
  • 20. Selection Sort ● Iteration-2 The array is scanned starting from the second to the last element and the element that has the smallest value is selected. The smallest value is 3 at location 4. The address of element that has the smallest value is noted. The selected value is interchanged with the second element i.e. A[2] and A[4] are swapped 1 19 4 3 1 3 4 19
  • 21. Selection Sort ● Iteration-3 The array is scanned starting from the third to the last element and the element that has the smallest value is selected. The smallest value is 4 at location 3. The address of element that has the smallest value is noted. The selected value is interchanged with the third element i.e. A[3] and A[3] are swapped 1 3 4 19 1 3 4 19
  • 23. Thank You Presented By Aung Myint Tun
  • 24. Do You Have Any Question!