Skip to content

Commit cdc531d

Browse files
committed
docs: Clean-up minor errors
1 parent 55f3046 commit cdc531d

File tree

8 files changed

+19
-17
lines changed

8 files changed

+19
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gradle is used for development.
1616
- Adelson-Velskii and Landis (AVL) Binary Search Tree
1717
- [Disjoint Set / Union Find](src/main/java/dataStructures/disjointSet)
1818
* [Quick Find](src/main/java/dataStructures/disjointSet/quickFind)
19-
* [Weighted Union]((src/main/java/dataStructures/disjointSet)/weightedUnion)
19+
* [Weighted Union](src/main/java/dataStructures/disjointSet/weightedUnion)
2020
* Path compression
2121
- [Hashing](src/main/java/dataStructures/hashSet)
2222
* [Chaining](src/main/java/dataStructures/hashSet/chaining)

src/main/java/algorithms/sorting/bubbleSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ largest (or smallest) element in the unsorted region to the sorted region (often
99
![bubble sort img](../../../../../../docs/assets/images/BubbleSort.jpeg)
1010

1111
### Implementation Invariant
12-
After the kth iteration, the biggest k items are correctly sorted at the final k positions of the array.
12+
**After the kth iteration, the biggest k items are correctly sorted at the final k positions of the array**.
1313

1414
The job of the kth iteration of the outer loop is to bubble the kth-largest element to the kth position of the array
1515
from the right (i.e. its correct position).

src/main/java/algorithms/sorting/countingSort/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ encountered. <br>
1111

1212
### Implementation Invariant
1313

14-
At the end of the ith iteration, the ith element (of the original array) from the back will be placed in
15-
its correct position.
14+
**At the end of the ith iteration, the ith element (of the original array) from the back will be placed in
15+
its correct position**.
1616

1717
Note: An alternative implementation from the front is easily done with minor modification.
1818
The catch is that this implementation would not be stable.
1919

2020
### Common Misconception
2121

22-
_Counting sort does not require total ordering of elements since it is non-comparison based._
22+
_"Counting sort does not require total ordering of elements since it is non-comparison based."_
2323

2424
This is incorrect. It requires total ordering of elements to determine their relative positions in the sorted output.
2525
In our implementation, the total ordering property is reflected by virtue of the structure of the frequency map.

src/main/java/algorithms/sorting/cyclicSort/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Though under some conditions (discussed later), the best case could be done in O
77

88
### Implementation Invariant
99

10-
At the end of the ith iteration, the ith element
11-
(of the original array, from either the back or front depending on implementation), is correctly positioned.
10+
**At the end of the ith iteration, the ith element
11+
(of the original array, from either the back or front depending on implementation), is correctly positioned**.
1212

1313
### Comparison to Selection Sort
1414

src/main/java/algorithms/sorting/insertionSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ it into arr[0, k-1] following sorted order, returning us arr[0, k] in sorted ord
1414
![InsertionSort](../../../../../../docs/assets/images/InsertionSort.png)
1515

1616
### Implementation Invariant
17-
The loop invariant: At the end of kth iteration, the first (k+1) items in the array are in sorted order.
17+
The loop invariant: **At the end of kth iteration, the first (k+1) items in the array are in sorted order**.
1818

1919
At the end of the (n-1)th iteration, all n items in the array will be in sorted order.
2020

src/main/java/algorithms/sorting/selectionSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ would be in the sorted array.
1313
Let the array of length n to be sorted be A.
1414

1515
The loop invariant is:
16-
At the end of the kth iteration, the smallest k items are correctly sorted in the first k positions of the array.
16+
**At the end of the kth iteration, the smallest k items are correctly sorted in the first k positions of the array**.
1717

1818
So, at the end of the (n-1)th iteration of the loop, the smallest (n-1) items are correctly sorted in the first (n-1)
1919
positions of the array, leaving the last item correctly positioned in the last index of the array. Therefore,

src/main/java/dataStructures/disjointSet/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ query if there already exists a path between 2 nodes.
1212

1313
Generally, there are 2 main operations:
1414

15-
1. Union: Join two subsets into a single subset
16-
2. Find: Determine which subset a particular element is in. In practice, this is often done to check
15+
1. **Union**: Join two subsets into a single subset
16+
2. **Find**: Determine which subset a particular element is in. In practice, this is often done to check
1717
if two elements are in the same subset or component.
1818

1919
The Disjoint Set structure is often introduced in 3 parts, with each iteration being better than the
@@ -27,12 +27,12 @@ Querying for connectivity and updating usually tracked with an internal array.
2727
a balanced tree and hence complexity does not necessarily improve
2828
- Note, this is not implemented but details can be found under weighted union folder.
2929

30-
3. **Weighted Union** - Same idea of using a tree, but constructed in a way that the tree is balanced, leading to improved
31-
complexities. Can be further augmented with path compression.
30+
3. **Weighted Union** - Same idea of using a tree, but constructed in a way that the tree is balanced, leading to
31+
4. improved complexities. Can be further augmented with path compression.
3232

3333
## Applications
3434
Because of its efficiency and simplicity in implementing, Disjoint Set structures are widely used in practice:
35-
1. As mentioned, it is often sued as a helper structure for Kruskal's MST algorithm
35+
1. As mentioned, it is often used as a helper structure for Kruskal's MST algorithm
3636
2. It can be used in the context of network connectivity
3737
- Managing a network of computers
3838
- Or even analyse social networks, finding communities and determining if two users are connected through a chain
@@ -42,4 +42,4 @@ Because of its efficiency and simplicity in implementing, Disjoint Set structure
4242

4343
## Notes
4444
Disjoint Set is a data structure designed to keep track of a set of elements partitioned into a number of
45-
non-overlapping subsets. It is not suited for handling duplicates and so our implementation ignores duplicates.
45+
non-overlapping subsets. **It is not suited for handling duplicates** and so our implementation ignores duplicates.

src/main/java/dataStructures/disjointSet/weightedUnion/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ objects of the smaller tree becomes part of the larger tree (by setting the root
4949

5050
Notice that trees will only increase in height when it's size is doubled. Working on this intuition, one can show
5151
(by induction) that a tree of height h has at least 2^h elements. Consequently,
52-
**a tree of size n is at most height of logn**.
52+
**a tree of size n is at most height of logn**. <br/>
53+
_Note: n = 2^(logn)_
5354

5455
### Implementation Details
5556
The concept introduces the idea of constructing trees and forests and certainly, one can similarly implement a
@@ -72,9 +73,10 @@ assigning to its grandparent actually suffice and yield the same big-O upper-bou
7273
done in a single pass.). By doing so, we greatly reduce the height of the trees formed.
7374

7475
The analysis with compression is a bit trickier here and talks about the inverse-Ackermann function.
75-
Interested readers can find out more [here](https://dl.acm.org/doi/pdf/10.1145/321879.321884)
76+
Interested readers can find out more [here](https://dl.acm.org/doi/pdf/10.1145/321879.321884).
7677

7778
**Time**: O(alpha)
79+
7880
**Space**: O(n)
7981

8082
## Notes

0 commit comments

Comments
 (0)