Skip to content

Commit 1ea2f4c

Browse files
committed
Merge branch 'main' into branch-Trie
2 parents aca6d01 + 63ea5ec commit 1ea2f4c

File tree

9 files changed

+51
-43
lines changed

9 files changed

+51
-43
lines changed

README.md

Lines changed: 24 additions & 18 deletions
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)
@@ -26,24 +26,26 @@ Gradle is used for development.
2626
- [Linked List](src/main/java/dataStructures/linkedList)
2727
- LRU Cache
2828
- Minimum Spanning Tree
29+
* Kruskal
30+
* Prim's
31+
* Boruvska
2932
- [Queue](src/main/java/dataStructures/queue)
3033
- [Deque](src/main/java/dataStructures/queue/Deque)
3134
- [Monotonic Queue](src/main/java/dataStructures/queue/monotonicQueue)
3235
- Segment Tree
33-
* Array implementation
34-
* TreeNode implementation
3536
- [Stack](src/main/java/dataStructures/stack)
3637
- Trie
3738

3839
## Algorithms
40+
- [Bubble Sort](src/main/java/algorithms/sorting/bubbleSort)
41+
- [Binary Search](src/main/java/algorithms/binarySearch)
42+
* [Template](src/main/java/algorithms/binarySearch/binarySearchTemplated)
3943
- [Counting Sort](src/main/java/algorithms/sorting/countingSort)
4044
- [Cyclic Sort](src/main/java/algorithms/sorting/cyclicSort)
4145
* [Special case](src/main/java/algorithms/sorting/cyclicSort/simple) of O(n) time complexity
4246
* [Generalized case](src/main/java/algorithms/sorting/cyclicSort/generalised) of O(n^2) time complexity
43-
- [Knuth-Morris-Pratt](src/main/java/algorithms/patternFinding) aka KMP algorithm
44-
- [Bubble Sort](src/main/java/algorithms/sorting/bubbleSort)
4547
- [Insertion Sort](src/main/java/algorithms/sorting/insertionSort)
46-
- [Selection Sort](src/main/java/algorithms/sorting/selectionSort)
48+
- [Knuth-Morris-Pratt](src/main/java/algorithms/patternFinding) aka KMP algorithm
4749
- Merge Sort
4850
* [Recursive](src/main/java/algorithms/sorting/mergeSort/recursive)
4951
* [Bottom-up iterative](src/main/java/algorithms/sorting/mergeSort/iterative)
@@ -52,41 +54,45 @@ Gradle is used for development.
5254
* [Lomuto's](src/main/java/algorithms/sorting/quickSort/lomuto)
5355
* [Paranoid](src/main/java/algorithms/sorting/quickSort/paranoid)
5456
* [3-way Partitioning](src/main/java/algorithms/sorting/quickSort/threeWayPartitioning)
55-
- [Radix Sort](src/main/java/algorithms/sorting/radixSort/)
57+
- [Radix Sort](src/main/java/algorithms/sorting/radixSort)
58+
- [Selection Sort](src/main/java/algorithms/sorting/selectionSort)
5659

57-
## Short-cut to CS2040S Material
60+
## CS2040S Syllabus (in rough order)
5861
1. Basic structures
5962
* [Linked List](src/main/java/dataStructures/linkedList)
6063
* [Stack](src/main/java/dataStructures/stack)
6164
* [Queue](src/main/java/dataStructures/queue)
6265
2. [Binary Search](src/main/java/algorithms/binarySearch)
6366
* Peak Finding
64-
* Simple Version
65-
* Universal Version
67+
* [Template](src/main/java/algorithms/binarySearch/binarySearchTemplated)
6668
3. Sorting
6769
* [Bubble](src/main/java/algorithms/sorting/bubbleSort)
6870
* [Insertion](src/main/java/algorithms/sorting/insertionSort)
6971
* [Selection](src/main/java/algorithms/sorting/selectionSort)
7072
* [Merge](src/main/java/algorithms/sorting/mergeSort)
7173
* [Quick](src/main/java/algorithms/sorting/quickSort)
74+
* [Hoare's](src/main/java/algorithms/sorting/quickSort/hoares)
75+
* [Lomuto's](src/main/java/algorithms/sorting/quickSort/lomuto) (Not discussed in CS2040s)
76+
* [Paranoid](src/main/java/algorithms/sorting/quickSort/paranoid)
77+
* [3-way Partitioning](src/main/java/algorithms/sorting/quickSort/threeWayPartitioning)
78+
* [Counting Sort](src/main/java/algorithms/sorting/countingSort) (found in tutorial)
79+
* [Radix Sort](src/main/java/algorithms/sorting/radixSort) (found in tutorial)
7280
4. Trees
7381
* [Binary search tree](src/main/java/dataStructures/binarySearchTree)
7482
* AVL-tree
83+
* Orthogonal Range Searching
84+
* Trie
85+
* B-Tree
86+
* * Red-Black Tree (Not covered in CS2040s but useful!)
7587
* Kd-tree (**WIP**)
7688
* Interval tree (**WIP**)
77-
* Augmented tree for orthogonal range searching
78-
* Red-Black Tree
79-
* ab-Tree
80-
5. [Binary Heap](src/main/java/dataStructures/heap)
81-
* Max heap implementation
89+
5. [Binary Heap](src/main/java/dataStructures/heap) (Max heap)
8290
6. [Disjoint Set / Union Find](src/main/java/dataStructures/disjointSet)
8391
* [Quick Find](src/main/java/dataStructures/disjointSet/quickFind)
84-
* [Weighted Union](src/main/java/dataStructures/disjointSet/weightedUnion)
85-
* Path compression
92+
* [Weighted Union](src/main/java/dataStructures/disjointSet/weightedUnion) (with path compression)
8693
7. [Hashing](src/main/java/dataStructures/hashSet)
8794
* [Chaining](src/main/java/dataStructures/hashSet/chaining)
8895
* [Open Addressing](src/main/java/dataStructures/hashSet/openAddressing)
89-
* Double Hashing
9096
* Bloom filter (**WIP**)
9197
8. Basic graphs (**WIP**)
9298
* Depth-first search

docs/team/profiles.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Team Profile
22

3-
| Name | Description/About | Website (LinkedIn/GitHub/Personal) | Contributions |
4-
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
5-
| Andre | An aspiring ML engineer. My stint as a CS2040s TA has convinced several capable and passionate students to join me in developing this project :) | You can find me [here](https://4ndrelim.github.io) as well! | Team lead |
6-
| Kai ting | ... | ... | Trees and Sorts! All sorts!<br/>Bubble, Insertion, Selection, Merge, Quick |
7-
| Changxian | ... | ... | Tricky Hashing and its variants |
8-
| Owen | ... | ... | Graphs and confusing mazes |
9-
| Shu Heng | Interested in ML, aspiring researcher. | No website but here's my [Linkedin](https://www.linkedin.com/in/yeoshuheng), please give me a job :< | Fundamentals! Linked List and its variants, Stacks & Queues and their variants |
10-
| Junneng | Aspiring tech entrepreneur. | [LinkedIn](https://www.linkedin.com/in/soo-jun-neng/) | Trees and Binary Search variants |
11-
| Amadeus | ... | ... | Graphs! Dijkstra .. |
3+
| Name | Description/About | Website (LinkedIn/GitHub/Personal) | Contributions |
4+
|-----------|----------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
5+
| Andre | Aspiring ML engineer. My stint as a CS2040s TA has convinced several capable and passionate students to develop this together :) | You can find me [here](https://4ndrelim.github.io)! | Team lead |
6+
| Kai ting | ... | ... | Cool sorting and obscure trees! B-Trees, ORS.. |
7+
| Changxian | ... | ... | Hashing variants! BTS DevOps - configure Gradle & workflows |
8+
| Shu Heng | Interested in ML, aspiring researcher. | No website but here's my [Linkedin](https://www.linkedin.com/in/yeoshuheng), please give me a job :< | CS Fundamentals! Stacks and queues! RB-tree. |
9+
| Junneng | Aspiring tech entrepreneur. | [LinkedIn](https://www.linkedin.com/in/soo-jun-neng/) | Binary Search variants, Minimum Spanning Trees! |
10+
| Amadeus | ... | ... | Graphs! |
11+
| Owen | ... | ... | Graphs and confusing mazes |

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)