Oracle, Web, Script, SQLserver, Tips & Trick

January 15, 2013

Contoh program pengurutan menggunakan algoritma Bubble Sort (Quick Basic)

Filed under: qbasic — sikathabis @ 3:37 am
Tags: ,

‘Contoh program pengurutan nomor laporan menggunakan algoritma Bubble Sort (QBASIC)

'Variabel array
DIM no(100) AS INTEGER
DIM nama(100) AS STRING

'Variabel sementara
DIM tmpno AS INTEGER
DIM tmpnama AS STRING
CONST maxdata = 4

CLS

'Data awal
no(1) = 2
nama(1) = "Iqbal"
no(2) = 4
nama(2) = "Reza"
no(3) = 1
nama(3) = "Fariz"
no(4) = 3
nama(4) = "Rangga"

PRINT "TAMPILAN SEBELUM DI SORT"
FOR i = 1 TO maxdata
    PRINT no(i); "    "; nama(i)
NEXT i

PRINT STRING$(80, "-")

'Proses pengurutan memakai algoritma Bubblesort
FOR i = 1 TO maxdata
    FOR j = i TO maxdata
        IF no(i) > no(j) THEN
            tmpno = no(i)
            no(i) = no(j)
            no(j) = tmpno
            tmpnama = nama(i)
            nama(i) = nama(j)
            nama(j) = tmpnama
        END IF
    NEXT j
NEXT i

PRINT "TAMPILAN SETELAH DI SORT BERDASARKAN NOMOR"
FOR i = 1 TO maxdata
    PRINT no(i); "    "; nama(i)
NEXT i

bubblesort
Menggunakan metode ini tergolong paling mudah algoritma-nya akan tetapi paling lama proses pengurutannya. 
Ada algoritma lain yang lebih cepat proses pengurutannya, seperti Quick Sort, Heap Sort ...

2 Comments »

  1. mas itu maksud angak 100 di “DIM no(100)” apa ya? Mohon penjelasannya

    Comment by Zulfa Nurul — January 6, 2014 @ 1:53 am | Reply

    • angka 100 merupakan maximum total data yang digunakan

      Comment by sikathabis — January 6, 2014 @ 2:07 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Teknologi Pendidikan

Just another WordPress.com weblog

KATAKAMI

Jurnalisme Yang Dapat Dipercaya

Tonk Kosonk Baonk Bunyinya

Penampungan Serapah Tanpa Sumpah

Qey050489's Blog

Ayo Bangkit sobat..!!!!!

B. S. Totoraharjo

Orang Bodoh Yang Tak Kunjung Pandai

culturekitchen foodlab

New Food and Art in Yogyakarta

Wahyu Catur Wibowo

Musafir Dunia Maya

SQL.... Still Learning

My Reference on SQL Server

neinframe

Street Photography is like a box of a chocolates, you're never know what you're gonna get - Thomas Leuthard -

Keluarga Andrivito

-- Andrivito's Journal --

DRK™

This site is about Latest NEWS, Articles, Videos, Books, Course, Presentations, Tips & Tricks related to I.T Pro's

Gaurav Saxena

|| तत् त्वम् असि ||

Be a good Moeslim

Menuju Pribadi Muslim Sejati yang Bertaqwa

TuanSUFI

Manajemen Sholat, renungan spiritual, Teknologi Informasi

Pelangi di khatulistiwa....

Mari berbagi kebaikan, pengalaman dan senyum denganku

angkasa13

Ceritanya saya, Pikirannya saya, Hatinya saya

sikathabis

sikathabis semua informasi disini

%d bloggers like this: