File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
classical_algorithms/dart Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ void Quicksort (list, int leftElement, int rightElement) {
2
+ int left = leftElement;
3
+ int right = rightElement;
4
+ int pivot = list[(leftElement + rightElement) ~ / 2 ];
5
+
6
+ while (left <= right) {
7
+ while (list[left] < pivot) {
8
+ left++ ;
9
+ }
10
+
11
+ while (list[right] > pivot) {
12
+ right-- ;
13
+ }
14
+
15
+ if (left <= right) {
16
+ int temp = list[left];
17
+ list[left] = list[right];
18
+ list[right] = temp;
19
+ left++ ;
20
+ right-- ;
21
+ }
22
+ }
23
+
24
+ if (leftElement < right) {
25
+ Quicksort (list, leftElement, right);
26
+ }
27
+
28
+ if (left < rightElement) {
29
+ Quicksort (list, left, rightElement);
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ Code | Test
35
35
Code | Test
36
36
------------ | -------------
37
37
[ Bubble Sort] ( https://github.com/larissalages/code_problems/blob/master/classical_algorithms/dart/BubbleSort.dart ) | Missing tests
38
+ [ Quick Sort] ( https://github.com/larissalages/code_problems/blob/master/classical_algorithms/dart/QuickSort.dart ) | Missing tests
38
39
39
40
### C++
40
41
Code | Test
You can’t perform that action at this time.
0 commit comments