Ijrar research Journal



Yüklə 0,49 Mb.
Pdf görüntüsü
səhifə4/8
tarix02.06.2023
ölçüsü0,49 Mb.
#115224
1   2   3   4   5   6   7   8
IJRAR19L2026

B.
 
Selection Sort 
Selection sort is the most simplistic algorithm but it’s inefficient. In selection sort, we have to find the smallest element doing 
the linear scan and move it to the front (swapping it with the front element). Then, we have to find the second smallest element 
and move it from its place, again doing a linear scan. Continue doing this until all the elements are at their place. In the selection 
sort algorithm, it maintains two sub-arrays in a given array. The first sub-array which is already sorted and the second remaining 
sub-array which is unsorted. Every Iteration of selection sort, the slightest element from the unsorted secondary the array is 
picked and moved to the sorted secondary array. Selection sort algorithm [6] used in the experiments below was described by 
C++ language as shown in fig 2:


© 2020 IJRAR September 2020, Volume 7, Issue 3 www.ijrar.org (
E-ISSN 2348-1269, P- ISSN 2349-5138

IJRAR19L2026 
International Journal of Research and Analytical Reviews (IJRAR) 
www.ijrar.org
 
116 
Fig. 2 Selection Sort Code 
Fig. 2 Example of Selection Sort [10] 
C.
 
Insertion Sort 
Insertion sort algorithm picks components individually and places it to the right position any place it has a place in the sorted 
lists of elements. Insertion sort is a simple yet efficient comparison sort for small data. Insertion Sort is reduced to its total number 
of steps if given a partially sorted list, increased efficiency. It’s practically more efficient than selection sort and a bubble sort, 
even though all of them have O(n*n) worst case complexity. Numbers are divided into sorted and unsorted. The unsorted values 
are put into their suitable positions in the sorted secondary array one by one. Insertion sort is well-organized for minor data sets 
but very incompetent for larger lists. It reduces its total number of steps if given a partially sorted list, increased efficiency.
Insertion sort algorithm [7] used in the experiments below was described by C++ language as shown in fig 3: 



Yüklə 0,49 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə