Database Programming Assignment

Added on - 01 Oct 2019

  • 7

    pages

  • 863

    words

  • 147

    views

  • 0

    downloads

Showing pages 1 to 3 of 7 pages
Blog: Selection Sort (Databaseprogramming)1
Selection Sort (Database programming)6thAugust 2019Selection Sort AlgorithmThe selection sort algorithm can be referred to as the process through which values are sorted.For sorting a data in the ascending order, a comparison is undertaken between the 0thelement andthe other elements. If it is found that the 0thelement is greater in value than the element it isbeing compared with, there is an interchange between the two values. What happens here is that,after the first iteration occurs, the element with the smallest value is placed at the 0thposition.The process is undertaken continuously until there is sorting out of the entire array. Selection sortcan be defined as the simplest sorting algorithm. It first finds out the smallest element within thearray and then it swaps that element with the one in the first position. After that, it searches forthe second smallest element and will swap it with the element in the second position. Thisprocess will be continued till the whole array has been sorted. The figure that is representedbelow depicts the technique in which the selection sort takes place.2
An example of the process through which selection sort is done in programming is as follows:#include<iostream>usingnamespacestd;intmain(){inta[100],i,n,p,k,min,loc,tmp;cout<<"\n------------ SELECTION SORT ------------ \n\n";3
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document