GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add bubble sort in Python (#812) · rabbitqyh/leetcode@bb44b78

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • basic/sorting/BubbleSort
    • BubbleSort.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎basic/sorting/BubbleSort/BubbleSort.py‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def bubbleSort(arr):
2+
n = len(arr)
3+
# Iterate over all array elements
4+
for i in range(n):
5+
# Last i elements are already in place
6+
for j in range(n - i - 1):
7+
if arr[j] > arr[j + 1]:
8+
arr[j], arr[j + 1] = arr[j + 1], arr[j]
9+
10+
11+
arr = [64, 34, 25, 12, 22, 11, 90]
12+
bubbleSort(arr)
13+
print(arr)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.