Go to your University || Python Lab || DSA Lab || AI & Machine Learning Lab || Linux Lab || OOPs Lab || DBMS Lab || JAVA Lab ||| Free Online Tutorials ||| 
companies for Campus Placement || Logical Reasoning || Quantitative Aptitude || General English || Technical-MCQ and Interview Questions || HR Interview Questions
0 like 0 dislike
34 views

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.8k 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 35 views
0 like 0 dislike
0 answers 15 views
0 like 0 dislike
1 answer 19 views
0 like 0 dislike
1 answer 121 views
  Realize your learning potential with courses starting at ₹ 420
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Online Free Training:  MACHINE LEARNINGPython Programming | Database Management System(DBMS) | Object Oriented Programming(OOPs) using C++ | Data Structures and Algorithms(DSA) | Java Programming | Linux/Unix | C Programming
Exams: List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...