Summer training at Goeduhub Technologies-Jaipur

Online Instructor-Led Live Training Courses/Workshops details || Claim for online workshop's certificate

0 like 0 dislike
16 views
in Tutorial & Interview questions by Goeduhub's Expert (7.3k points)

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.3k points)
 
Best answer

The selection sort algorithm sorts an array by repeatedly finding the minimum element  from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.

1) The subarray which is already sorted.
2) Remaining subarray which is unsorted.

In every iteration of selection sort, the minimum element from the unsorted subarray is picked and moved to the sorted subarray.       

Time Complexity: O(n2)

Worst Complexity :  n^2

Average Complexity :  n^2

Auxiliary Space: O(1)

selection-sort-python

Python program for implementation of Selection Sort:

a=[64, 34, 25, 82, 22, 11, 90]

for i in range(len(a)):

    b=i

    for j in range(i+1,len(a)):

        if a[b]>a[j]:

            b=j

    a[i],a[b]=a[b],a[i]

print(a)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-Kota | BTU-Bikaner | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...