FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
1 like 0 dislike
597 views
in Python Programming by Goeduhub's Expert (9.3k points)

1 Answer

0 like 0 dislike
by Goeduhub's Expert (9.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)

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

1 like 0 dislike
1 answer 489 views
0 like 1 dislike
0 answers 292 views
1 like 0 dislike
1 answer 416 views
1 like 0 dislike
1 answer 685 views

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...