SlideShare a Scribd company logo
1 of 8
   The selection sort is a combination of searching
    and sorting.
   In selection sort, sorting is done after selecting a
    particular smallest or largest element from an
    array and shifted it to a particular location in an
    array.
   During each pass, the unsorted element with the
    smallest (or largest) value is moved to its proper
    position in the array.
   Let's look at our same table of elements using a
    selection sort for ascending order:
Array     40     50         60         10             30         20

       1-pass   10     50         60         40             30         20
       2-pass 10        20         60         40             30         50

        3-pass 10       20         30             40         60         50

          4-pass 10          20         30         40             60         50

           5-pass 10         20         30             40         50         60
   The number of times the sort passes through the
    array is one less than the number of items in the
    array.
   In the selection sort, the inner loop finds the next
    smallest (or largest) value and the outer loop
    places that value into its proper location.
   Lets watch a video which will give you a basic idea
    of a selection sort.
   Please co-operate.
   Lets look at coding of it in c++:
   #include<iostream>
   using namespace std;
   void selectionsort(int *array,int length)
   {
       int i,j,min,minat,temp;
       for(i=0;i<(length-1);i++)
       {
                  minat=i;
                  min=array[i];
                  for(j=0;j<length;j++)
                  {
                            if(min>array[j])
                            {
                                     minat=j;
                                     min=array[j];
                            }
                  }
       temp=array[i];
       array[i]=array[minat];
       array[minat]=temp;
       }
   }
   void printelements(int *array,int length)
   {
     int i;
     for(i=0;i<length;i++)
            cout<<array[i]<<” “<<;
   }
   int main()
   {
       int array[100],n,i;
       cout<<”enter number of element you wants to enter in an array”;
       cin>>n;
       if(n<0)
       {
                cout<<”enter proper positive element”;
                cin>>n;
       }
       for(i=0;i<n;i++)
       {
                cout<<”enter values in array”;
                cin>>array[i];
       }
       selectionsort(array,n);
       printelement(array,n);
       return 0;
   }
   Any query?
   Any question or any point which you doesn’t get?
Selection sort

More Related Content

What's hot

Insertion sort
Insertion sortInsertion sort
Insertion sortalmaqboli
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure Janki Shah
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms ManishPrajapati78
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked ListsAfaq Mansoor Khan
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting AlgorithmsRahul Jamwal
 
Linear Search
Linear SearchLinear Search
Linear SearchSWATHIR72
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Hossain Md Shakhawat
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithmNeoClassical
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 

What's hot (20)

Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Quick sort
Quick sortQuick sort
Quick sort
 
Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point Selection sort algorithm presentation, selection sort example using power point
Selection sort algorithm presentation, selection sort example using power point
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Stacks
StacksStacks
Stacks
 
Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting Algorithms
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 

Viewers also liked

Selection sort
Selection sortSelection sort
Selection sortasra khan
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sortgeeortiz
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sortKrish_ver2
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary SearchReem Alattas
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-SortTareq Hasan
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1asmhemu
 
Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)oDesk
 
Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort AlgorithmTobias Straub
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sortKrish_ver2
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topicSaddam Hussain
 

Viewers also liked (20)

Selection sort
Selection sortSelection sort
Selection sort
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sort
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sort
 
The selection sort algorithm
The selection sort algorithmThe selection sort algorithm
The selection sort algorithm
 
Selection Sort
Selection SortSelection Sort
Selection Sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
Sorting
SortingSorting
Sorting
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
 
Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)Sorting (Bubble,Merge,Selection sort)
Sorting (Bubble,Merge,Selection sort)
 
Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort Algorithm
 
Binary search
Binary searchBinary search
Binary search
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
3.1 bubble sort
3.1 bubble sort3.1 bubble sort
3.1 bubble sort
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
 
Quicksort
QuicksortQuicksort
Quicksort
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Quick sort
Quick sortQuick sort
Quick sort
 

Similar to Selection sort

Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2sotlsoc
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxKalpana Mohan
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfMohammed472103
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL乐群 陈
 
Bin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. TrinidadBin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. TrinidadLUISITO TRINIDAD
 
Parsing swiftly-Cocoaheads-2015-02-12
Parsing swiftly-Cocoaheads-2015-02-12Parsing swiftly-Cocoaheads-2015-02-12
Parsing swiftly-Cocoaheads-2015-02-12griotspeak
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Anwar Patel
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method Shantanu Mishra
 
Unit3 jwfiles
Unit3 jwfilesUnit3 jwfiles
Unit3 jwfilesmrecedu
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfsaneshgamerz
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
C++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfC++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfRahul04August
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09Terry Yoast
 

Similar to Selection sort (20)

Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
 
Bin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. TrinidadBin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. Trinidad
 
Parsing swiftly-Cocoaheads-2015-02-12
Parsing swiftly-Cocoaheads-2015-02-12Parsing swiftly-Cocoaheads-2015-02-12
Parsing swiftly-Cocoaheads-2015-02-12
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
 
C Language Unit-3
C Language Unit-3C Language Unit-3
C Language Unit-3
 
Unit3 jwfiles
Unit3 jwfilesUnit3 jwfiles
Unit3 jwfiles
 
Lecture 7 arrays
Lecture   7 arraysLecture   7 arrays
Lecture 7 arrays
 
07 Arrays
07 Arrays07 Arrays
07 Arrays
 
Arrays
ArraysArrays
Arrays
 
9 Arrays
9 Arrays9 Arrays
9 Arrays
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdf
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
C++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfC++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdf
 
Huraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docxHuraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docx
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
 

More from Jay Patel

Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
Assignment 1(web)
Assignment 1(web)Assignment 1(web)
Assignment 1(web)Jay Patel
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)Jay Patel
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
Anchored data type
Anchored data typeAnchored data type
Anchored data typeJay Patel
 
Mutlimedia authoring tools
Mutlimedia authoring toolsMutlimedia authoring tools
Mutlimedia authoring toolsJay Patel
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software toolsJay Patel
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 textJay Patel
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 textJay Patel
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermediaJay Patel
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software toolsJay Patel
 

More from Jay Patel (20)

Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
Quiz(web)
Quiz(web)Quiz(web)
Quiz(web)
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
Assignment 1(web)
Assignment 1(web)Assignment 1(web)
Assignment 1(web)
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Unit1
Unit1Unit1
Unit1
 
Cursor
CursorCursor
Cursor
 
Anchored data type
Anchored data typeAnchored data type
Anchored data type
 
Mutlimedia authoring tools
Mutlimedia authoring toolsMutlimedia authoring tools
Mutlimedia authoring tools
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software tools
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 text
 
Sound
SoundSound
Sound
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 text
 
Images
ImagesImages
Images
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermedia
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software tools
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Selection sort

  • 1.
  • 2. The selection sort is a combination of searching and sorting.  In selection sort, sorting is done after selecting a particular smallest or largest element from an array and shifted it to a particular location in an array.  During each pass, the unsorted element with the smallest (or largest) value is moved to its proper position in the array.  Let's look at our same table of elements using a selection sort for ascending order:
  • 3. Array 40 50 60 10 30 20 1-pass 10 50 60 40 30 20 2-pass 10 20 60 40 30 50 3-pass 10 20 30 40 60 50 4-pass 10 20 30 40 60 50 5-pass 10 20 30 40 50 60  The number of times the sort passes through the array is one less than the number of items in the array.  In the selection sort, the inner loop finds the next smallest (or largest) value and the outer loop places that value into its proper location.  Lets watch a video which will give you a basic idea of a selection sort.  Please co-operate.
  • 4. Lets look at coding of it in c++:  #include<iostream>  using namespace std;  void selectionsort(int *array,int length)  {  int i,j,min,minat,temp;  for(i=0;i<(length-1);i++)  {  minat=i;  min=array[i];  for(j=0;j<length;j++)  {  if(min>array[j])  {  minat=j;  min=array[j];  }  }  temp=array[i];  array[i]=array[minat];  array[minat]=temp;  }  }
  • 5. void printelements(int *array,int length)  {  int i;  for(i=0;i<length;i++)  cout<<array[i]<<” “<<;  }
  • 6. int main()  {  int array[100],n,i;  cout<<”enter number of element you wants to enter in an array”;  cin>>n;  if(n<0)  {  cout<<”enter proper positive element”;  cin>>n;  }  for(i=0;i<n;i++)  {  cout<<”enter values in array”;  cin>>array[i];  }  selectionsort(array,n);  printelement(array,n);  return 0;  }
  • 7. Any query?  Any question or any point which you doesn’t get?