Alpro : Quick sort

799 views

Published on

Algoritma Quick Short

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
799
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Alpro : Quick sort

  1. 1. QUICK SORT Algoritma Pengurutan
  2. 2. SIMULASI QUICKSORT
  3. 3. RESULT
  4. 4. SIMULASI ALGORITMA QUICKSORT
  5. 5. QuickSORT(Array, indexawal, indexakhir) indexawal indexakhir data QuickSORT(data, 1,5)
  6. 6. QuickSORT(data, 1, 5) indexawal indexakhir data STEP 1 IF(indexawal < indexakhir)
  7. 7. See Code Indexhigher pivot While index lower < index higher Indexlower Cek Lower Cek Higher If(indexlower < index higher) Swap Swap QuickSORT(data, indexawal, indexhigher-1) QuickSORT(data, indexawal, indexhigher+1)
  8. 8. Indexhigher pivot Indexlower While index lower < index higher
  9. 9. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  10. 10. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  11. 11. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  12. 12. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  13. 13. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  14. 14. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  15. 15. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  16. 16. Indexhigher pivot Indexlower While index lower < index higher If(indexlower < index higher) Swap
  17. 17. Indexhigher pivot Indexlower While index lower < index higher If(indexlower < index higher) Swap
  18. 18. Indexhigher pivot Indexlower While index lower < index higher
  19. 19. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  20. 20. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  21. 21. Indexhigher pivot Indexlower While index lower < index higher Cek Lower
  22. 22. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  23. 23. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  24. 24. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  25. 25. Indexhigher pivot Indexlower While index lower < index higher Cek Higher
  26. 26. Indexhigher pivot Indexlower While index lower < index higher If(indexlower < index higher) Swap
  27. 27. Indexhigher pivot Indexlower Swap
  28. 28. Indexhigher pivot Indexlower Swap
  29. 29. Indexhigher pivot Indexlower Quicksorting(1,2) Quicksorting(4,5)
  30. 30. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher
  31. 31. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Lower
  32. 32. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Lower
  33. 33. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Lower
  34. 34. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Lower
  35. 35. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Higher
  36. 36. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Higher
  37. 37. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Higher
  38. 38. Indexhigher pivot Indexlower Quicksorting(1,2) If(indexlower < index higher) While index lower < index higher Swap
  39. 39. Indexhigher pivot Indexlower Quicksorting(1,2) Swap
  40. 40. pivot Indexhigher Indexlower Quicksorting(1,2) Quicksorting(1,0) Quicksorting(2,2)
  41. 41. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher
  42. 42. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Lower
  43. 43. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Lower
  44. 44. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Lower
  45. 45. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Lower
  46. 46. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Lower
  47. 47. Indexhigher pivot Indexlower Quicksorting(4,5) While index lower < index higher Cek Higher
  48. 48. Indexhigher pivot Indexlower Quicksorting(1,2) While index lower < index higher Cek Higher
  49. 49. Indexhigher pivot Indexlower Quicksorting(4,5) If(indexlower < index higher) While index lower < index higher Swap
  50. 50. Indexhigher pivot Indexlower Quicksorting(1,2) Swap
  51. 51. Indexhigher pivot Indexlower Quicksorting(4,5) Quicksorting(4,4) Quicksorting(6,5)
  52. 52. RESULT
  53. 53. TERIMAKASIH
  54. 54. C Code for QuickSORT void quicksort(int arr[max],int arrawal,int arrakhir){ int pivot,indexhigher,temp,indexlower; if(arrawal<arrakhir){ pivot = arrawal; indexlower = arrawal; indexhigher = arrakhir; while(indexlower<indexhigher){ while((arr[indexlower]<=arr[pivot])&&(indexlower<arrakhir)){ indexlower++; } while(arr[indexhigher]>arr[pivot]&&(indexhigher>arrawal)){ indexhigher--; } if(indexlower<indexhigher){ swap(arr,indexlower,indexhigher); } } swap(arr,pivot,indexhigher); quicksort(arr,arrawal,indexhigher-1); quicksort(arr,indexhigher+1,arrakhir); } }//end
  55. 55. Swap code void swap (int a[max], int left, int right){ int temp; temp=a[left]; a[left]=a[right]; a[right]=temp; }//end swap
  56. 56. Cek Lower If(data[indexlower] <= data[pivot] && indexlower < indexakhir ) Indexlower = indexlower + 1
  57. 57. Cek Higher If(data[indexhigher] > data[pivot]) Indexhigher = indexhigher + 1

×