menu_book Course Curriculum (Data Structures & Algorithms) expand_more
Complexity & Foundations
Arrays & Strings
Linked Lists
Stacks & Queues
Hashing
Trees & Heaps
Graphs
Bubble sort
Learn Bubble sort in Data Structures & Algorithms with a focused explanation, a topic-specific example, edge guidance, and a mastery check.
12 min read
•
Advanced
Advertisement
data-structures-algorithms-071.py
python
a=[5,1,4,2]
for end in range(len(a)-1,0,-1):
for i in range(end):
if a[i]>a[i+1]:a[i],a[i+1]=a[i+1],a[i]
print(a)
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content