Finance[US] Career Guide Free Tutorials Go to Your University Placement Preparation 
1 like 0 dislike
623 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

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order and make them in ascending order .

Worst and Average Case Time Complexity: O(n*n). Worst case occurs when array is reverse sorted.

Best Case Time Complexity: O(n). Best case occurs when array is already sorted.

Auxiliary Space: O(1)

Bubble-sort-algorithm-explaination

Python program for implementation of Bubble Sort 

arr=[5,1,4,2,8]

n = len(arr)

 for i in range(n):

    for j in range(0, n-i-1):

        if arr[j] > arr[j+1] :

            arr[j], arr[j+1] = arr[j+1], arr[j]

 print(arr)

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

0 like 1 dislike
0 answers 256 views
1 like 0 dislike
1 answer 367 views
1 like 0 dislike
1 answer 431 views
1 like 0 dislike
1 answer 532 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

...