Skip to content

This repository contains design and implementation of fundamental data structures and algorithms.

Notifications You must be signed in to change notification settings

4ndrelim/data-structures-and-algorithms

Repository files navigation

Data Structures & Algorithms

A complementary resource for learning fundamental data structures and algorithms. Aligned with CS2040S taught by Prof Seth Gilbert at NUS.

Each topic includes implementation, intuition, complexity analysis, and practical considerations. Useful for:

  • CS2040S students - Supplement lecture content with working implementations
  • Interview prep - Review fundamental DSA topics with clear explanations
  • CS students - Quick refresher on core concepts

Developed by CS2040S Teaching Assistants and alumni under Prof Seth's guidance.


Data Structures

Structure Description
AVL Tree Self-balancing BST with height-balance property
B-Tree Self-balancing tree optimized for disk access
Binary Search Tree Ordered tree structure
Disjoint Set / Union Find Quick Find, Weighted Union with path compression
Hash Set Chaining, Open Addressing
Heap Binary max heap
Linked List Singly linked list with sorting
LRU Cache Hash map + doubly linked list
Queue Deque, Monotonic Queue
Red-Black Tree Self-balancing BST with color invariants
Segment Tree Range queries with point updates
Stack LIFO with monotonic stack discussion
Trie Prefix tree for string operations

Algorithms

Sorting

Algorithm Variants
Bubble Sort Basic comparison sort
Insertion Sort Efficient for small/nearly sorted arrays
Selection Sort Simple O(n²) sort
Merge Sort Recursive, Iterative
Quick Sort Hoare's, Lomuto's, Paranoid, 3-way
Counting Sort Integer sorting in O(n + k)
Radix Sort Digit-by-digit sorting
Cyclic Sort Simple, Generalized

Searching & Graphs

Algorithm Description
Binary Search Standard and templated versions
Minimum Spanning Tree Prim's, Kruskal's
Orthogonal Range Searching Range trees for multi-dimensional queries

String Algorithms

Algorithm Description
KMP Knuth-Morris-Pratt pattern matching

CS2040S Syllabus Reference

Click to expand syllabus mapping
  1. Basic Structures: Linked List, Stack, Queue
  2. Binary Search: Peak finding, templated search
  3. Sorting: Bubble, Insertion, Selection, Merge, Quick, Counting, Radix
  4. Trees: BST, AVL, Trie, B-Tree, Segment Tree, Red-Black Tree, Orthogonal Range Searching
  5. Binary Heap
  6. Disjoint Set / Union Find
  7. Hashing
  8. Graphs: BFS, DFS, Bellman-Ford, Dijkstra, Topological Sort (coming soon)
  9. Minimum Spanning Tree: Prim, Kruskal

Getting Started

git clone https://github.com/4ndrelim/data-structures-and-algorithms.git
cd data-structures-and-algorithms
./gradlew clean test

For detailed setup with IntelliJ IDEA and Java SDK configuration, see the Developer Guide.

Usage

Browse implementations directly on GitHub, or clone locally to experiment. See the scripts folder for running algorithms with custom inputs.

Disclaimer

While we have verified correctness, there may be discrepancies with current lecture content. Please raise issues or consult your TA if you spot any concerns.

Contributors

See the team!

About

This repository contains design and implementation of fundamental data structures and algorithms.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages