Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update1: Bubble Sort(Removing Extra Iterations)
Removed the extra iterations in simple bubble_sort() function, so as the real meaning of bubble sort come out.
  • Loading branch information
kehsihba19 authored Oct 1, 2019
commit 9c2ebd063902379066fec50cccf312d4d4c0bacc
5 changes: 3 additions & 2 deletions Sorting/1. Bubble_Sort.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"outputs": [],
"source": [
"def bubble_sort(array):\n",
" for i in range(len(array) - 1):\n",
" for j in range(len(array) - 1):\n",
" n=len(array)",
" for i in range(0,n):\n",
" for j in range(0,n-i-1):\n",
" if array[j] > array[j + 1]:\n",
" array[j], array[j + 1] = array[j + 1], array[j] # swap"
]
Expand Down