Vaudilla. Praktikum1
Vaudilla. Praktikum1
PRAKTIKUM
Nama : Vaudilla
Nim : 13020200017
2. Andi Ikram
MAKASSAR
A. Code program
#include <iostream>
int x = arr[h];
int i = (l - 1);
if (arr[j] <= x) {
i++;
swap(arr[i], arr[j]);
return (i + 1);
int stack[h-l+1];
stack[++top]=l;
stack[++top]=h;
while(top >= 0)
h = stack[top--];
l = stack[top--];
if(p-1>l)
{
stack[++top] = l;
stack[++top] = p - 1;
if(p+1<h)
stack[++top] = p + 1;
stack[++top] = h;
partitionIndex++;
return partitionIndex;
quickSort (a,start,partitionIndex-1);
quickSort (a,partitionIndex+1,end);
}
}
int main()
int a[n];
cout << "Masukkan Nilai ke - " << x+1 << " : " ;
cout << "Masukkan Pilihan [1..2] :" << endl; cin >> pilih;
cout<<endl;
if ( pilih == 1) {
cout << "Pengurutan data dengan iterative quick sort" << endl;
for(int x=0;x<n;x++)
quick_sort(a,0,n-1);
cout << " Data setelah diurutkan " << endl;
for(int x=0;x<n;x++)
cout<<a[x]<<" ";
cout<<endl;
else if ( pilih == 2) {
cout << "Pengurutan data dengan rekursive quick sort" << endl;
for(int x=0;x<n;x++)
quickSort (a,0,n-1);
for(int x=0;x<n;x++)
cout<<a[x]<<" ";
cout<<endl;
}
B. Output