SlideShare a Scribd company logo
4
Most read
5
Most read
7
Most read
Selection sort algorithm presentation, selection sort example using power point
#Presentation submitted to:
Sohrab Hossain, Assistant professor of CSE
FSET,USTC
#Presentation submitted by:
Md Abdul Kuddus
Department of CSE
ID:15010102
Batch:25th
#Presentation Name:
Write a program to sort the element of
an array using selection sort.
#What is selection sort??
 Repeatedly searches for the largest value in a section of the
data
 Moves that value into its correct position in a sorted
section of the list
 Uses the Find Largest algorithm
#Example:
Given array: 34 8 64 51 32 21
sorted comparison item unsorted
comparison time
0 1 2 3 4 5
*pass 1: compare 1st position with minimum item
After pass1
*pass2: compare 2nd position with next minimum item
After pass2
34 8 64 51 21
8
34 64 51 218
34 64 51 21
8 21 64 51 34
*pass3: compare 3rd position with next minimum item
After pass3
*pass4: compare 4th position with next minimum item
After pass4
Array is sorted
8 21 64 51 34
8 21 34 51 64
8 21 34 51 64
8 21 34 51 64
*Algorithm:
Algorithm SELECTION(A,N)
Step1 : Repeat steps 2 and 3 for k=1,2,….N-1;
Step2 : Call MIN(A,K,N,LOC).
Step3: [Interchange A[k] and A[LOC].]
Set TEMP:=A[k],
A[k]:=A[LOC] and
A[LOC]:=TEMP.
[End of step 1 loop]
Step4:Exit.
#source code:
#include <stdio.h>
int *selectionSort(int A[],int n)
{
int j ,k ,temp;
for (k= 0; k < n; k++)
{
for(j = k+1; j < n; j++)
{
if(A[k] > A[j])
{
temp = A[k];
A[k] = A[j];
A[j] = temp;
}
}
}
return A;
}
int main()
{
int A[1000],k,n;
printf("Enter the number of element you want to Sort : ");
scanf("%d",&n);
printf("Enter Elements in the list : ");
for(k = 0; k < n; k++)
{
scanf("%d",&A[k]);
}
int *sortArray = selectionSort(A,n);
printf("Sorted list : ");
for(k = 0; k < n; k++ )
{
printf("%dt",sortArray[k]);
}
}
#Time efficiency
 Comparisons: n(n-1)/2
 Exchanges: n (swapping largest into place)
 Overall: (n2), best and worst cases
#Space efficiency
 Space for the input sequence, plus a constant number of local
variables
Selection sort algorithm presentation, selection sort example using power point

More Related Content

What's hot (20)

PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PPTX
Selection sort
smlagustin
 
PPT
Selection sort
stella D
 
PPTX
Insertion sort
Monalisa Patel
 
PPTX
Quick sort-Data Structure
Jeanie Arnoco
 
PPTX
Ppt bubble sort
prabhakar jalasutram
 
PDF
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
PPTX
Quicksort Presentation
irdginfo
 
PPTX
Linear and Binary search
Nisha Soms
 
PDF
Stack
Zaid Shabbir
 
PPTX
Searching techniques in Data Structure And Algorithm
03446940736
 
PPT
Quick Sort
priyankanaidu6
 
PPTX
Data Structures : hashing (1)
Home
 
PDF
Expression trees
Salman Vadsarya
 
PPT
Arrays
SARITHA REDDY
 
PPTX
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
PPTX
Insertion sort
MYER301
 
PPTX
Linear search-and-binary-search
International Islamic University
 
PPTX
Searching & Sorting Algorithms
Rahul Jamwal
 
PPT
stack presentation
Shivalik college of engineering
 
Priority Queue in Data Structure
Meghaj Mallick
 
Selection sort
smlagustin
 
Selection sort
stella D
 
Insertion sort
Monalisa Patel
 
Quick sort-Data Structure
Jeanie Arnoco
 
Ppt bubble sort
prabhakar jalasutram
 
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
Quicksort Presentation
irdginfo
 
Linear and Binary search
Nisha Soms
 
Searching techniques in Data Structure And Algorithm
03446940736
 
Quick Sort
priyankanaidu6
 
Data Structures : hashing (1)
Home
 
Expression trees
Salman Vadsarya
 
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Insertion sort
MYER301
 
Linear search-and-binary-search
International Islamic University
 
Searching & Sorting Algorithms
Rahul Jamwal
 

Similar to Selection sort algorithm presentation, selection sort example using power point (20)

PPTX
sorting1.pptx
AJAYVISHALRP
 
PDF
465659705-15-DSA-PPT-Sorting-Techniques-I.pdf
anushasanapathi1
 
PPTX
Data structure presentation sorting
Pranjali Rawat
 
DOCX
DAA Lab Work.docx
Deepusri2000Srivasta
 
PPT
Unit 7 sorting
kalyanineve
 
PPTX
ppt2- sorting data in design and anlysis.pptx
ShivaniSharma335055
 
PPSX
Sorting and searching
kalyanineve
 
PPT
Data Structure (MC501)
Kamal Singh Lodhi
 
PPTX
Selection sort 1
asmhemu
 
PPTX
Data Structure and algorithms for software
ManishShukla712917
 
PDF
L 14-ct1120
Zia Ush Shamszaman
 
PPT
Sorting algorithms
CHANDAN KUMAR
 
PPT
search_sort Search sortSearch sortSearch sortSearch sort
Shanmuganathan C
 
PPT
search_sort search_sortsearch_sort search_sortsearch_sortsearch_sortsearch_sort
Kanupriya731200
 
PPT
Selection sort
amna izzat
 
PDF
Selection sort
Abdelrahman Saleh
 
PDF
Sorting
Gopi Saiteja
 
PPTX
Unit vii sorting
Tribhuvan University
 
PDF
Sorting
Kariman Karm Gabaa
 
sorting1.pptx
AJAYVISHALRP
 
465659705-15-DSA-PPT-Sorting-Techniques-I.pdf
anushasanapathi1
 
Data structure presentation sorting
Pranjali Rawat
 
DAA Lab Work.docx
Deepusri2000Srivasta
 
Unit 7 sorting
kalyanineve
 
ppt2- sorting data in design and anlysis.pptx
ShivaniSharma335055
 
Sorting and searching
kalyanineve
 
Data Structure (MC501)
Kamal Singh Lodhi
 
Selection sort 1
asmhemu
 
Data Structure and algorithms for software
ManishShukla712917
 
L 14-ct1120
Zia Ush Shamszaman
 
Sorting algorithms
CHANDAN KUMAR
 
search_sort Search sortSearch sortSearch sortSearch sort
Shanmuganathan C
 
search_sort search_sortsearch_sort search_sortsearch_sortsearch_sortsearch_sort
Kanupriya731200
 
Selection sort
amna izzat
 
Selection sort
Abdelrahman Saleh
 
Sorting
Gopi Saiteja
 
Unit vii sorting
Tribhuvan University
 
Ad

Recently uploaded (20)

PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Ad

Selection sort algorithm presentation, selection sort example using power point

  • 2. #Presentation submitted to: Sohrab Hossain, Assistant professor of CSE FSET,USTC #Presentation submitted by: Md Abdul Kuddus Department of CSE ID:15010102 Batch:25th
  • 3. #Presentation Name: Write a program to sort the element of an array using selection sort. #What is selection sort??  Repeatedly searches for the largest value in a section of the data  Moves that value into its correct position in a sorted section of the list  Uses the Find Largest algorithm
  • 4. #Example: Given array: 34 8 64 51 32 21 sorted comparison item unsorted comparison time 0 1 2 3 4 5
  • 5. *pass 1: compare 1st position with minimum item After pass1 *pass2: compare 2nd position with next minimum item After pass2 34 8 64 51 21 8 34 64 51 218 34 64 51 21 8 21 64 51 34
  • 6. *pass3: compare 3rd position with next minimum item After pass3 *pass4: compare 4th position with next minimum item After pass4 Array is sorted 8 21 64 51 34 8 21 34 51 64 8 21 34 51 64 8 21 34 51 64
  • 7. *Algorithm: Algorithm SELECTION(A,N) Step1 : Repeat steps 2 and 3 for k=1,2,….N-1; Step2 : Call MIN(A,K,N,LOC). Step3: [Interchange A[k] and A[LOC].] Set TEMP:=A[k], A[k]:=A[LOC] and A[LOC]:=TEMP. [End of step 1 loop] Step4:Exit.
  • 8. #source code: #include <stdio.h> int *selectionSort(int A[],int n) { int j ,k ,temp; for (k= 0; k < n; k++) { for(j = k+1; j < n; j++) { if(A[k] > A[j]) { temp = A[k]; A[k] = A[j]; A[j] = temp; } } } return A; }
  • 9. int main() { int A[1000],k,n; printf("Enter the number of element you want to Sort : "); scanf("%d",&n); printf("Enter Elements in the list : "); for(k = 0; k < n; k++) { scanf("%d",&A[k]); } int *sortArray = selectionSort(A,n); printf("Sorted list : "); for(k = 0; k < n; k++ ) { printf("%dt",sortArray[k]); } }
  • 10. #Time efficiency  Comparisons: n(n-1)/2  Exchanges: n (swapping largest into place)  Overall: (n2), best and worst cases #Space efficiency  Space for the input sequence, plus a constant number of local variables