Quick Sort

  • June 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 Quick Sort as PDF for free.

More details

  • Words: 130
  • Pages: 1
*********************************************************************** var A : array[1..1000] of integer; // Array yang ingin di-sort N : integer; // Banyaknya data yang ingin di-sort procedure qsort(l,r:integer); // Quick sort - ascending (menaik) var i,j,x,buff : integer; begin i := l; j := r; x := A[(i+j) div 2]; while (i < j) do begin while (A[i] < x) do inc(i); // Bagian ini dapat diubah untuk menjadikannya descending while (x < A[j]) do dec(j); // Bagian ini dapat diubah untuk menjadikannya descending if (i <= j) then begin buff := A[i]; A[i] := A[j]; A[j] := buff; inc(i); dec(j); end; end; if (i < r) then qsort(i,r); if (l < j) then qsort(l,j); end; begin // Isi array A terlebih dahulu qsort(1,N); // Sort array A dari index 1 sampai N end. ***********************************************************************

Related Documents

Quick Sort
May 2020 4
Quick Sort
July 2020 6
Quick Sort
June 2020 6
Quick Sort
May 2020 20
Ex-17 Quick Sort
October 2019 5
Junaid (quick Sort)
April 2020 9