Bubble Sort - Isi F.docx

  • Uploaded by: Muhammad Fauzi Maulana
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Bubble Sort - Isi F.docx as PDF for free.

More details

  • Words: 221
  • Pages: 3
1. Introduction Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent pairs and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort. Bubble sort can be practical if the input is in mostly sorted order with some out-of-order elements nearly in position. 2. Flowchart START

def BubbleSort(Num)

for group1 in range(len(Num)-1,0,-1)

End

for i in range(group1)

Num[i]>Num[i+1] ?

temp = Num[i] Num[i] = Num[i+1] Num[i+1] = temp

BUBBLE SORT – DATA STRUCTURE | 1

3. Program

def BubbleSort(Num): for group1 in range(len(Num)-1,0,-1): for i in range(group1): if Num[i]>Num[i+1]: temp = Num[i] Num[i] = Num[i+1] Num[i+1] = temp

Numbers = [100,11,5,23,6,17,88,69,66,15] BubbleSort(Numbers) print(Numbers)

BUBBLE SORT – DATA STRUCTURE | 2

4. Data The data is 100, 11, 5, 23, 6, 17, 88, 69, 66 and 15 5. Result The result is will be sorted like this : 5, 6, 11, 15, 17, 23, 66, 69, 88 and 100

BUBBLE SORT – DATA STRUCTURE | 3

Related Documents

Bubble Sort
May 2020 17
Bubble Sort
May 2020 22
Bubble Sort
June 2020 8
Bubble Sort With Flag
April 2020 16
Parallel Bubble Sort
May 2020 18

More Documents from "Wayan Sriyasa"