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
107 views

1 Answer

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

Related questions

0 like 0 dislike
0 answers 11 views
0 like 0 dislike
1 answer 18 views
0 like 0 dislike
1 answer 31 views
0 like 0 dislike
1 answer 25 views
 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::   |  | 

 

...