Skip to content

Commit bc8573d

Browse files
committed
docs: quicksort readme cleanup
1 parent 9b5238e commit bc8573d

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

src/main/java/algorithms/sorting/quickSort/hoares/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ Note that the usual Hoare's QuickSort differs slightly from lecture implementati
55

66
This version of QuickSort assumes the **absence of duplicates** in our array.
77

8+
## Background
9+
810
QuickSort is a sorting algorithm based on the divide-and-conquer strategy. It works by selecting a pivot element from
911
the array and rearranging the elements such that all elements less than the pivot are on its left, and
1012
all elements greater than the pivot are on its right. This effectively partitions the array into two parts. The same
1113
process is then applied recursively to the two partitions until the entire array is sorted.
1214

13-
Implementation Invariant:
15+
## Implementation Invariant:
1416

1517
The pivot is in the correct position, with elements to its left being < it, and elements to its right being > it.
1618

1719
![Lecture Hoare's QuickSort](../../../../../../../docs/assets/images/LectureHoares.jpeg)
1820
Example Credits: Prof Seth/Lecture Slides
1921

2022
## Complexity Analysis
21-
22-
Complexity Analysis: (this analysis is based on fixed index pivot selection)
23+
* This analysis is based on fixed index pivot selection.
24+
* The complexity analysis for Hoare's quicksort is the same as that of Lomuto's quicksort.
2325

2426
Time:
2527

src/main/java/algorithms/sorting/quickSort/lomuto/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ then swap the pivot back to its correct position. Below is an illustration:
2323
The pivot is in the correct position, with elements to its left being <= it, and elements to its right being > it.
2424

2525
## Complexity Analysis:
26-
Time:
26+
* The complexity analysis for Lomuto's quicksort is the same as that of Hoare's quicksort.
27+
Time:
2728
- Expected worst case (poor choice of pivot): O(n^2)
2829
- Expected average case: O(nlogn)
2930
- Expected best case (balanced pivot): O(nlogn)

src/main/java/algorithms/sorting/quickSort/paranoid/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Paranoid QuickSort
22

3-
### Background
3+
## Background
44
Paranoid Quicksort is the naive quicksort with an additional check to guarantee a good pivot.
55

66
![ParanoidQuickSort](../../../../../../../docs/assets/images/ParanoidQuickSort.jpeg)
77

8-
### Complexity Analysis:
8+
## Complexity Analysis:
99
Time: (this analysis assumes the absence of many duplicates in our array)
1010
- Expected worst case: O(nlogn)
1111
- Expected average case: O(nlogn)

src/main/java/algorithms/sorting/quickSort/threeWayPartitioning/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Three-Way Partitioning
22

3-
### Background
3+
## Background
44
Three-way partitioning is used in QuickSort to tackle the scenario where there are many duplicate elements in the
55
array being sorted.
66

@@ -10,11 +10,11 @@ and swaps with duplicate elements, making the sorting process more efficient.
1010

1111
![ThreeWayPartitioning](../../../../../../../docs/assets/images/ThreeWayPartitioning.jpeg)
1212

13-
### Implementation Invariant:
13+
## Implementation Invariant:
1414
The pivot and any element numerically equal to the pivot will be in the correct positions in the array. Elements
1515
to their left are < them and elements to their right are > than them.
1616

17-
### Complexity Analysis:
17+
## Complexity Analysis:
1818
Time:
1919
- Worst case: O(nlogn)
2020
- Average case: O(nlogn)

0 commit comments

Comments
 (0)