Skip to content

Commit 4c0cf98

Browse files
committed
Merge from main
2 parents 9e00f17 + 85ff02c commit 4c0cf98

File tree

168 files changed

+6952
-6857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+6952
-6857
lines changed

.github/workflows/gradle.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '11'
23+
distribution: 'temurin'
24+
- name: Build with Gradle
25+
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
26+
with:
27+
arguments: build --no-daemon

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
.gradle
1010

1111
# Ignore Gradle build output directory
12-
build
12+
build/

README.md

Lines changed: 91 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,144 @@
11
# Data Structures & Algorithms
2-
This repository contains implementation of some fundamental data structures and algorithms in Computer Science. It is primarily used as a teaching resource and is currently being developed by ex-2040s students.
32

4-
The project uses Gradle and the structure is optimised for IntelliJ IDEA since implementation are mostly written in Java.
3+
This repository contains implementation and discussion notes (intuition, applications, analysis)
4+
of some fundamental data structures and algorithms in Computer Science. <br>
5+
It is aligned with [CS2040s](https://nusmods.com/courses/CS2040S/data-structures-and-algorithms) syllabus taught by
6+
[Prof Seth](https://www.comp.nus.edu.sg/cs/people/gilbert/) at NUS.
57

6-
**Note**: This is still being developed. Those below with links mean that they are complete (alongside testing). We project to complete CS2040s course content by November and along the way, add interesting algorithms/problems. We are hopeful that the subsequent batches of students (from AY23/24 S2) will benefit greatly from this.
8+
The work here is continually being developed by CS2040s Teaching Assistants(TAs) and ex-2040s students,
9+
under the guidance of Prof Seth.
10+
It is still in its infant stage, mostly covering lecture content and discussion notes.
11+
Future plans include deeper discussion into the tougher parts of tutorials and even practice problems / puzzles related
12+
to DSA.
713

8-
If you wish to contribute, do drop an email at [email protected].
14+
The project's structure is optimised for IntelliJ IDEA as per the course's preferred IDE.
15+
Gradle is used for development.
916

10-
## Full List of Implementation (in alphabetical order):
11-
## Structures
12-
- Adelson-Velskii and Landis (AVL) Binary Search Tree
13-
- Disjoint Set / Union Find
14-
* Quick Find
15-
* Weighted Union
16-
* Path compression
17+
## Full List (in alphabetical order):
18+
19+
## Data Structures
20+
- [Adelson-Velskii and Landis (AVL) Binary Search Tree](src/main/java/dataStructures/avlTree)
21+
- [Disjoint Set / Union Find](src/main/java/dataStructures/disjointSet)
22+
* [Quick Find](src/main/java/dataStructures/disjointSet/quickFind)
23+
* [Weighted Union](src/main/java/dataStructures/disjointSet/weightedUnion)
24+
* Path compression
1725
- [Hashing](src/main/java/dataStructures/hashSet)
1826
* [Chaining](src/main/java/dataStructures/hashSet/chaining)
1927
* [Open Addressing](src/main/java/dataStructures/hashSet/openAddressing)
2028
- [Heap](src/main/java/dataStructures/heap)
21-
* Max heap implementation
29+
* Max heap implementation
2230
- [Linked List](src/main/java/dataStructures/linkedList)
2331
- LRU Cache
24-
- Minimum Spanning Tree
32+
- Minimum Spanning Tree
33+
* Kruskal
34+
* Prim's
35+
* Boruvska
2536
- [Queue](src/main/java/dataStructures/queue)
37+
- [Deque](src/main/java/dataStructures/queue/Deque)
38+
- [Monotonic Queue](src/main/java/dataStructures/queue/monotonicQueue)
2639
- Segment Tree
27-
* Array implementation
28-
* TreeNode implementation
2940
- [Stack](src/main/java/dataStructures/stack)
30-
- Trie
31-
41+
- [Trie](src/main/java/dataStructures/trie)
3242

3343
## Algorithms
44+
- [Bubble Sort](src/main/java/algorithms/sorting/bubbleSort)
45+
- [Binary Search](src/main/java/algorithms/binarySearch)
46+
* [Template](src/main/java/algorithms/binarySearch/binarySearchTemplated)
3447
- [Counting Sort](src/main/java/algorithms/sorting/countingSort)
3548
- [Cyclic Sort](src/main/java/algorithms/sorting/cyclicSort)
3649
* [Special case](src/main/java/algorithms/sorting/cyclicSort/simple) of O(n) time complexity
3750
* [Generalized case](src/main/java/algorithms/sorting/cyclicSort/generalised) of O(n^2) time complexity
38-
- [Knuth-Morris-Pratt](src/main/java/algorithms/patternFinding) aka KMP algorithm
39-
- [Bubble Sort](src/main/java/algorithms/sorting/bubbleSort)
4051
- [Insertion Sort](src/main/java/algorithms/sorting/insertionSort)
41-
- [Selection Sort](src/main/java/algorithms/sorting/selectionSort)
42-
- Merge Sort
52+
- [Knuth-Morris-Pratt](src/main/java/algorithms/patternFinding) aka KMP algorithm
53+
- [Merge Sort](src/main/java/algorithms/sorting/mergeSort)
4354
* [Recursive](src/main/java/algorithms/sorting/mergeSort/recursive)
4455
* [Bottom-up iterative](src/main/java/algorithms/sorting/mergeSort/iterative)
45-
- Quick Sort
56+
- [Quick Sort](src/main/java/algorithms/sorting/quickSort/)
4657
* [Hoare's](src/main/java/algorithms/sorting/quickSort/hoares)
4758
* [Lomuto's](src/main/java/algorithms/sorting/quickSort/lomuto)
4859
* [Paranoid](src/main/java/algorithms/sorting/quickSort/paranoid)
4960
* [3-way Partitioning](src/main/java/algorithms/sorting/quickSort/threeWayPartitioning)
50-
- Radix Sort
51-
61+
- [Radix Sort](src/main/java/algorithms/sorting/radixSort)
62+
- [Selection Sort](src/main/java/algorithms/sorting/selectionSort)
5263

53-
## Short-cut to CS2040S Material
64+
## CS2040S Syllabus (in rough order)
5465
1. Basic structures
5566
* [Linked List](src/main/java/dataStructures/linkedList)
5667
* [Stack](src/main/java/dataStructures/stack)
5768
* [Queue](src/main/java/dataStructures/queue)
58-
2. Binary Search
69+
2. [Binary Search](src/main/java/algorithms/binarySearch)
5970
* Peak Finding
60-
* Template
71+
* [Template](src/main/java/algorithms/binarySearch/binarySearchTemplated)
6172
3. Sorting
6273
* [Bubble](src/main/java/algorithms/sorting/bubbleSort)
6374
* [Insertion](src/main/java/algorithms/sorting/insertionSort)
6475
* [Selection](src/main/java/algorithms/sorting/selectionSort)
6576
* [Merge](src/main/java/algorithms/sorting/mergeSort)
6677
* [Quick](src/main/java/algorithms/sorting/quickSort)
78+
* [Hoare's](src/main/java/algorithms/sorting/quickSort/hoares)
79+
* [Lomuto's](src/main/java/algorithms/sorting/quickSort/lomuto) (Not discussed in CS2040s)
80+
* [Paranoid](src/main/java/algorithms/sorting/quickSort/paranoid)
81+
* [3-way Partitioning](src/main/java/algorithms/sorting/quickSort/threeWayPartitioning)
82+
* [Counting Sort](src/main/java/algorithms/sorting/countingSort) (found in tutorial)
83+
* [Radix Sort](src/main/java/algorithms/sorting/radixSort) (found in tutorial)
6784
4. Trees
68-
* Binary search tree
69-
* AVL-tree
70-
* Kd-tree
71-
* Interval tree
72-
* Augmented tree for orthogonal range searching
73-
* Red-Black Tree
74-
* ab-Tree
75-
5. [Binary Heap](src/main/java/dataStructures/heap)
76-
* Max heap implementation
77-
6. Disjoint Set / Union Find
78-
* Quick Find
79-
* Weighted Union
80-
* Path compression
85+
* [Binary search tree](src/main/java/dataStructures/binarySearchTree)
86+
* [AVL-tree](src/main/java/dataStructures/avlTree)
87+
* [Trie](src/main/java/dataStructures/trie)
88+
* [B-Tree](src/main/java/dataStructures/bTree)
89+
* Red-Black Tree (Not covered in CS2040s but useful!)
90+
* Orthogonal Range Searching (**WIP**)
91+
* Interval Trees (**WIP**)
92+
5. [Binary Heap](src/main/java/dataStructures/heap) (Max heap)
93+
6. [Disjoint Set / Union Find](src/main/java/dataStructures/disjointSet)
94+
* [Quick Find](src/main/java/dataStructures/disjointSet/quickFind)
95+
* [Weighted Union](src/main/java/dataStructures/disjointSet/weightedUnion) (with path compression)
8196
7. [Hashing](src/main/java/dataStructures/hashSet)
8297
* [Chaining](src/main/java/dataStructures/hashSet/chaining)
8398
* [Open Addressing](src/main/java/dataStructures/hashSet/openAddressing)
84-
* Double Hashing
85-
* Bloom filter
86-
8. Basic graphs
99+
* Bloom filter (**WIP**)
100+
8. Basic graphs (**WIP**)
87101
* Depth-first search
88102
* Breadth-first search
89-
9. Graphs
103+
9. Graphs (**WIP**)
90104
* Bellman-ford
91105
* Dijkstra
92-
* Directed acyclic graphs
93-
10. Minimum spanning tree
94-
* Prim's
106+
* Directed acyclic graphs algorithms
107+
* Post-order DFS
108+
* Kahn's
109+
* Floyd Warshall
110+
10. Minimum spanning tree (**WIP**)
111+
* Prim's
95112
* Kruskal's
96113

114+
## Set-up
115+
If you are a CS2040s student, your IDEA configurations should already be compatible with this project structure. So,
116+
feel free to clone and use it as you see fit. Note, below configuration is as per CS2040s PS1 set-up guide.
117+
118+
1. Choose Java Version 11.0.XX for Project SDK. You can download it [here](https://www.oracle.com/java/technologies/downloads/#java11)
119+
- Create account and login if necessary
120+
- Make sure to download the correct one compatible with your hardware
121+
2. Download IntelliJ (Community Edition) [here](https://www.jetbrains.com/idea/download/?section=mac) if you do not have it.
122+
3. Fork the repo and clone it on your local device
123+
4. Launch IntelliJ on your device and under the `Projects` tab, and click `open`. Navigate to where the local repo is
124+
cloned
125+
1. Configure to Java SDK (if not done) by first heading to `File` on the top-left panel,
126+
2. Click on `Project Structure...`
127+
3. Apply the desired Java SDK in the `SDK:` dropdown. Remember to click `Apply`.
128+
5. You can test if everything is properly set-up with the command: <br/>
129+
`./gradlew clean test` <br/>
130+
All files should be compiled and all testcases should pass.
131+
132+
## Usage
133+
The resources here can be directly viewed from GitHub interface, but it is advisable for you to fork and clone
134+
it to your local desktop, especially if you wish to tweak or play with custom inputs. There is a folder where you can
135+
import and run the algorithms/structures here for your own input. See [here](scripts/README.md).
97136

98-
## Running Custom Inputs
99-
See [here](scripts/README.md).
137+
## Disclaimer
138+
While our team of TAs and students have diligently verified the correctness of our code, there might still be
139+
some discrepancies or deviation from lecture content (perhaps due to new changes).
140+
In which case, **you are strongly advised to raise it up to us or consult your TA** regarding any suspicions
141+
on the use of the information shared here.
100142

101143
## Contributors
102144
See the [team](docs/team/profiles.md)!

0 commit comments

Comments
 (0)