Skip to content

gkonovalov/algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithms and Data Structures

Donald Knuth: "An algorithm must be seen to be believed".

Welcome to curated GitHub repository, featuring a comprehensive collection of fundamental Algorithms and Data structures organized into various categories to cater to the needs of software engineers and computer science students. Each Algorithm and Data structure is systematically classified, ensuring easy navigation and efficient learning. You will find concise explanations and clear Java implementation code, making it easy to understand and implement the concepts in your projects.

Additionally, the repository includes sample problems and solutions, designed to help practice and apply the concepts learned from each Algorithm and Data structure. These problems serve as valuable exercises to enhance your problem-solving skills.

Algorithms

Algorithms
├── Arrays
│   ├── Searching
│   │   ├── Linear Search
│   │   ├── Binary Search
│   │   ├── Exponential Search
│   │   ├── Jump Search
│   │   ├── Interpolation Search
│   │   └── Ternary Search
│   ├── Sorting
│   │   ├── Bubble Sort
│   │   ├── Selection Sort
│   │   ├── Insertion Sort
│   │   ├── Merge Sort
│   │   ├── Quick Sort
│   │   │   ├── Partition Hoare
│   │   │   ├── Partition Lomuto
│   │   │   └── 3-Way Partitioning
│   │   ├── Heap Sort
│   │   ├── Counting Sort
│   │   └── Bucket Sort
│   └── Selection
│       ├── Quick Select
│       │   ├── Partition Hoare
│       │   └── Partition Lomuto
│       └── Median of medians
├── Strings
│   ├── Sorting
│   │   └── LSD Radix Sort
│   ├── Compression
│   │   └── Huffman Coding
│   └── String Matching
│       ├── Naive String Search
│       ├── Brute-force
│       ├── Rabin-Karp
│       ├── Knuth-Morris-Pratt
│       ├── Boyer-Moore
│       ├── Aho-Corasick
│       ├── Regular Expressions
│       │   ├── Regular Expression Matching
│       │   └── Thompson NFA
│       └── Edit Distance
│           ├── Levenshtein Distance
│           └── Hamming Distance
├── Linked List
│   └── Floyd's Cycle Detection
├── Tree
│   └── Searching
│       ├── DFS
│       │   ├── Pre-order traversal
│       │   ├── In-order traversal
│       │   └── Post-order traversal
│       └── BFS 
│           └── Level-order traversal
├── Graphs
│   ├── Searching
│   │ 	├── DFS 
│   │ 	│   ├── Path 
│   │ 	│   └── DFS-ID
│   │ 	├── BFS
│   │ 	│   ├── Path 
│   │   │   └── Bidirectional BFS
│   │ 	└── Shortest Path
│   │ 	    ├── BFS
│   │ 	    ├── Dijkstra's
│   │ 	    │   ├── Eager
│   │ 	    │   └── Lazy
│   │ 	    ├── Bellman–Ford
│   │ 	    ├──	Floyd-Warshall
│   │ 	    └── A-star
│   ├── Minimum Spanning Tree
│   │   ├── Prim’s
│   │   │   ├── Eager
│   │   │   └── Lazy
│   │ 	└── Kruskal’s
│   ├── Network Flow
│   │   ├── Maximum Flow
│   │   │   ├── Ford-Fulkerson
│   │   │   ├── Edmonds-Karp
│   │   │   ├── Push-Relabel
│   │   │   └── Dinic's
│   │   ├── Minimum Cut 
│   │   │   └── Karger's
│   │   └── Maximum Bipartite
│   ├── Sorting
│   │ 	└── Topological Sort
│   │       ├── Kahn's
│   │       └── Tarjan's 
│   ├── Connectivity
│   │   ├── Bridge
│   │   ├── Connectivity
│   │   ├── Connected Components
│   │   ├── Strongly Connected Components
│   │   │   ├── Kosaraju-Sharir's
│   │   │   └── Tarjan's
│   │   └── Union-Find
│   │        ├── Quick Find
│   │        └── Quick Union
│   │            ├── Weighted
│   │            └── Weighted with Path Compression
│   ├── Cycle Detection
│   ├── Is Bipartite
│   ├── Graph coloring
│   ├── Eulerian Path
│   ├── Eulerian Cycle
│   ├── Hamiltonian Path
│   └── Hamiltonian Cycle
├── Divide and Conquer
│   ├── Binary Search
│   ├── Merge Sort
│   ├── Quick Sort
│   └── Strassen's Matrix multiplication
├── Recursion
│   ├── Factorial
│   ├── Dynamic Programming
│   │   ├── Approaches
│   │   │   ├── Top-Down  - Memoization
│   │   │   └── Bottom-Up - Tabulation
│   │   ├── Fibonacci Numbers
│   │ 	├── Bellman–Ford
│   │ 	├── Floyd-Warshall
│   │   ├── Levenshtein Distance
│   │   ├── Regular Expression Matching
│   │   ├── Matrix Chain Multiplication
│   │   └── Binomial Coefficient
│   └── Backtracking
│       └── Combinatorics
│           ├── Permutations
│           ├── Combinations
│           ├── Subsets
│           └── Partitions
├── Greedy
│   ├── Huffman Coding
│   ├── Dijkstra's Lazy
│   └── Minimum Spanning Tree
│       ├── Prim’s Lazy
│       └── Kruskal’s
├── Randomized
│   ├── Randomized Quick Sort
│   ├── Fisher-Yates Shuffle
│   ├── Randomized Quick Select
│   ├── Las Vegas
│   └── Monte Carlo
├── Game Theory
│   ├── Minimax
│   └── Prisoner's Dilemma
├── Geometry
│   ├── Closest Pair of Points
│   ├── Line Intersection
│   ├── Voronoi Diagram
│   ├── Delaunay Triangulation
│   └── Convex Hull
│       ├── Graham Scan
│       └── Jarvis March
├── Bits Operations
└── Math
    ├── Fibonacci Numbers
    ├── Factorial
    ├── Prime Numbers
    │   ├── Sieve of Eratosthenes
    │   ├── Primality Tests
    │   │   ├── Trial Division
    │   │   ├── Fermat
    │   │   └── Miller-Rabin
    │   └── Prime Factorizations
    │       ├── Trial Division
    │       └── Wheel Factorization
    ├── GCD Euclidean Algorithm
    ├── Fast Exponentiation
    ├── Catalan Numbers
    ├── Binomial Coefficient
    ├── Pascal Triangle
    ├── Least Common Multiple (LCM)
    ├── Sum of Digits
    ├── Power of Two
    ├── Euclidean Distance
    └── Matrix
        ├── Inversion
        ├── Transposition
        ├── Square Rotation
        └── Multiplication  
            ├── Exponentiation 
            ├── Sparse Matrix
            ├── Chain
            └── Strassen's

Data Structures

Data Structures
├── String
├── Arrays
│   ├── Array
│   ├── Dynamic Array
│   └── Suffix Arrays
├── Linked Lists
│   ├── Singly  
│   ├── Doubly 
│   └── Skip List
├── Stacks
├── Queues
│   ├── Queue
│   ├── Deque
│   └── Circular Queue
├── Hash Tables
│   ├── HashMap
│   ├── HashSet
│   ├── Sparse Vector
│   └── Collision Resolution
│       ├── Separate Chaining
│       └── Open Addressing
├── Bloom Filter 
├── Trees
│   ├── Binary Search Tree
│   ├── Trie-trees
│   │    ├── Prefix Tree - Trie
│   │    └── Suffix Tree
│   ├── Heaps
│   │   ├── Binary Heap - Priority Queue
│   │   │   ├── Min Heap
│   │   │   └── Max Heap
│   │   ├── Indexed Binary Heap
│   │   └── Fibonacci Heaps
│   ├── Self-balanced
│   │   ├── AVL Tree
│   │   ├── Red Black Tree
│   │   ├── B Tree
│   │   │   └── B+ Tree
│   │   ├── 2-3 Tree
│   │   ├── Splay Tree
│   │   └── Treaps
│   ├── Cartesian Tree
│   ├── K-D Tree
│   ├── Fenwick Tree
│   └── Segment Tree
└── Graphs
    ├── Types
    │   ├── Undirected Graph
    │   ├── Directed Graph
    │   ├── Weighted Undirected Graph
    │   ├── Weighted Directed Graph
    │   ├── Cyclic Graph
    │   ├── Acyclic Graph
    │   ├── Directed Acyclic Graph
    │   ├── Labeled Graph
    │   ├── Bipartite Graph
    │   ├── Tree
    │   ├── Forest
    │   └── Spanning Tree
    └── Representation in memory
        ├── Adjacency List
        ├── Adjacency Matrix
        └── Edge List

Coding Problems and Techniques

Problems
├── Arrays
│   ├── Sorting
│   │   ├── Merge Intervals
│   │   ├── Merge Sorted Array
│   ├── Searching
│   │   └── Binary Search
│   │       ├── Capacity to Ship Packages Within N Days
│   │       ├── Cutting Ribbons
│   │       ├── Find First and Last Position of Element in Sorted Array
│   │       ├── Find Peak Element
│   │       ├── First Bad Version
│   │       ├── Koko Eating Bananas
│   │       ├── Missing Number
│   │       ├── Search Insert Position
│   │       └── Search Rotated Sorted Array
│   ├── Selection
│   │   ├── Kth Closest Points to Origin
│   │   └── Kth Largest Element in Array
│   ├── Sliding Window
│   ├── Two Pointers
│   │   └── Container With Most Water
│   ├── Matrix
│   │   ├── Game of Life
│   │   ├── Rotate Image
│   │   ├── Search in 2D Matrix
│   │   └── Set Matrix Zeroes
│   ├── Maximum Sum Subarray - Kadane's 
│   ├── Prefix Sum
│   └── Range Sum 
├── Strings
│   ├── Spelling Correction
│   ├── Reverse String
│   ├── Anagram Checking
│   └── Palindromes
│       ├── Palindrome Checking
│       ├── Palindrome Substrings
│       └── Longest Palindromic Substring
├── Linked List
│   ├── Add Two Numbers
│   ├── Intersection of Two Linked Lists
│   ├── Merge Two Sorted Lists
│   ├── Palindrome Linked List
│   ├── Remove Nth Node From End of List
│   ├── Sort List
│   ├── Cycle
│   │   ├── Linked List Cycle
│   │   └── Linked List Cycle II
│   ├── Reversal
│   │   ├── Reverse Linked List
│   │   └── Reverse Linked List II
│   └── Cache
│       ├── LRU
│       └── LFU 
├── Stacks
│   ├── Simplify Path
│   ├── Valid Parentheses
│   └── Basic Calculator II
├── Queues
├── Hash Table
│   ├── Group Anagrams
│   ├── Logger Rate Limiter
│   ├── Roman to Integer
│   └── Verifying an Alien Dictionary
├── Trees
│   ├── Maximum Depth of Binary Tree
│   ├── Binary Tree Inorder Traversal
│   ├── Binary Tree Maximum Path Sum
│   ├── Binary Tree Right Side View
│   ├── Binary Tree Vertical Order Traversal
│   ├── Boundary of Binary Tree
│   ├── Lowest Common Ancestor of a Binary Tree
│   ├── Diameter of Binary Tree
│   ├── Invert Binary Tree
│   ├── Recover Binary Search Tree
│   ├── Same Tree
│   ├── Validate Binary Search Tree
│   ├── Heap
│   │   └── Merge k Sorted Lists
│   ├── Trie
│   │   └── Longest Common Prefix
│   └── N-ary Tree
│       ├── Clone N-ary Tree
│       ├── Diameter of N-Ary Tree
│       └── Maximum Depth of N-ary Tree
├── Graphs
│   ├── Is Graph Bipartite
│   ├── Sorting
│   │   └── Topological Sort
│   │       └── Alien Dictionary
│   └── Searching
│       ├── BFS
│       │   ├── Number of Islands
│       │   ├── Word Break
│       │   └── Word Ladder
│       └── DFS
│           ├── Clone Graph
│           ├── Island Perimeter
│           ├── Walls and Gates
│           ├── Spiral Matrix
│           └── Word Search
├── Recursion
│   ├── Dynamic Programming
│   │   ├── Fibonacci Numbers
│   │   ├── Knapsack 0/1
│   │   ├── Knapsack Unbounded
│   │   ├── Traveling Salesman
│   │   ├── Longest Common Subsequence (LCS)
│   │   ├── Longest Increasing Subsequence (LIS) 
│   │   ├── Longest Palindrome Subsequence (LPS)
│   │   ├── Shortest Common Supersequence (SCS)
│   │   ├── Maximum Sum Increasing Subsequence
│   │   ├── Maximum Subarray Sum
│   │   ├── Combination Sum
│   │   ├── Rod Cutting
│   │   ├── Jump Game
│   │   ├── Partition problem
│   │   ├── Russian Dolls Envelope
│   │   ├── Dungeon Game
│   │   ├── Subset Sum problem
│   │   ├── Minimum Path Sum
│   │   ├── Unique Paths in a Grid
│   │   ├── Counting Paths in a Grid
│   │   ├── Wildcard Matching
│   │   ├── Word Break
│   │   ├── Paint House
│   │   ├── Palindrome Partitioning
│   │   ├── Maximum Product Subarray
│   │   ├── Staircase
│   │   └── Coin Change
│   └── Backtracking
│       ├── Traveling Salesman
│       ├── N-Queens
│       ├── Knight's Tour 
│       ├── Sudoku Solver
│       ├── Unique Paths
│       ├── Rat in a Maze 
│       ├── Subset Sum
│       └── Word Search
├── Greedy
│   ├── Knapsack
│   ├── Interval Scheduling
│   ├── Job Scheduling 
│   └── Coin Change
├── Game Theory
│   └── Guess The Word
├── Bit Manipulation
└── NP-complete problems
     ├── Traveling Salesman
     ├── Knapsack Unbounded
     ├── SAT
     ├── Clique
     ├── Factorization
     └── Hamiltonian Cycle

Requirements

JDK 8.0 or later.

Development

To open the project in Intellij Idea:

  1. Go to File menu or the Welcome Screen
  2. Click on Open...
  3. Navigate to algorithms root directory.
  4. Select setting.gradle

Georgiy Konovalov 2024 (c) MIT License