|
1 | 1 | # 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. |
3 | 2 |
|
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. |
5 | 7 |
|
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. |
7 | 13 |
|
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. |
9 | 16 |
|
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 |
17 | 25 | - [Hashing](src/main/java/dataStructures/hashSet)
|
18 | 26 | * [Chaining](src/main/java/dataStructures/hashSet/chaining)
|
19 | 27 | * [Open Addressing](src/main/java/dataStructures/hashSet/openAddressing)
|
20 | 28 | - [Heap](src/main/java/dataStructures/heap)
|
21 |
| - * Max heap implementation |
| 29 | + * Max heap implementation |
22 | 30 | - [Linked List](src/main/java/dataStructures/linkedList)
|
23 | 31 | - LRU Cache
|
24 |
| -- Minimum Spanning Tree |
| 32 | +- Minimum Spanning Tree |
| 33 | + * Kruskal |
| 34 | + * Prim's |
| 35 | + * Boruvska |
25 | 36 | - [Queue](src/main/java/dataStructures/queue)
|
| 37 | + - [Deque](src/main/java/dataStructures/queue/Deque) |
| 38 | + - [Monotonic Queue](src/main/java/dataStructures/queue/monotonicQueue) |
26 | 39 | - Segment Tree
|
27 |
| - * Array implementation |
28 |
| - * TreeNode implementation |
29 | 40 | - [Stack](src/main/java/dataStructures/stack)
|
30 |
| -- Trie |
31 |
| - |
| 41 | +- [Trie](src/main/java/dataStructures/trie) |
32 | 42 |
|
33 | 43 | ## 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) |
34 | 47 | - [Counting Sort](src/main/java/algorithms/sorting/countingSort)
|
35 | 48 | - [Cyclic Sort](src/main/java/algorithms/sorting/cyclicSort)
|
36 | 49 | * [Special case](src/main/java/algorithms/sorting/cyclicSort/simple) of O(n) time complexity
|
37 | 50 | * [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) |
40 | 51 | - [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) |
43 | 54 | * [Recursive](src/main/java/algorithms/sorting/mergeSort/recursive)
|
44 | 55 | * [Bottom-up iterative](src/main/java/algorithms/sorting/mergeSort/iterative)
|
45 |
| -- Quick Sort |
| 56 | +- [Quick Sort](src/main/java/algorithms/sorting/quickSort/) |
46 | 57 | * [Hoare's](src/main/java/algorithms/sorting/quickSort/hoares)
|
47 | 58 | * [Lomuto's](src/main/java/algorithms/sorting/quickSort/lomuto)
|
48 | 59 | * [Paranoid](src/main/java/algorithms/sorting/quickSort/paranoid)
|
49 | 60 | * [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) |
52 | 63 |
|
53 |
| -## Short-cut to CS2040S Material |
| 64 | +## CS2040S Syllabus (in rough order) |
54 | 65 | 1. Basic structures
|
55 | 66 | * [Linked List](src/main/java/dataStructures/linkedList)
|
56 | 67 | * [Stack](src/main/java/dataStructures/stack)
|
57 | 68 | * [Queue](src/main/java/dataStructures/queue)
|
58 |
| -2. Binary Search |
| 69 | +2. [Binary Search](src/main/java/algorithms/binarySearch) |
59 | 70 | * Peak Finding
|
60 |
| - * Template |
| 71 | + * [Template](src/main/java/algorithms/binarySearch/binarySearchTemplated) |
61 | 72 | 3. Sorting
|
62 | 73 | * [Bubble](src/main/java/algorithms/sorting/bubbleSort)
|
63 | 74 | * [Insertion](src/main/java/algorithms/sorting/insertionSort)
|
64 | 75 | * [Selection](src/main/java/algorithms/sorting/selectionSort)
|
65 | 76 | * [Merge](src/main/java/algorithms/sorting/mergeSort)
|
66 | 77 | * [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) |
67 | 84 | 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) |
81 | 96 | 7. [Hashing](src/main/java/dataStructures/hashSet)
|
82 | 97 | * [Chaining](src/main/java/dataStructures/hashSet/chaining)
|
83 | 98 | * [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**) |
87 | 101 | * Depth-first search
|
88 | 102 | * Breadth-first search
|
89 |
| -9. Graphs |
| 103 | +9. Graphs (**WIP**) |
90 | 104 | * Bellman-ford
|
91 | 105 | * 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 |
95 | 112 | * Kruskal's
|
96 | 113 |
|
| 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). |
97 | 136 |
|
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. |
100 | 142 |
|
101 | 143 | ## Contributors
|
102 | 144 | See the [team](docs/team/profiles.md)!
|
0 commit comments