Skip to content

Highly optimized & performant search algorithms for BSTs, graphs, and arrays, implemented in both C++ and Python.

Notifications You must be signed in to change notification settings

forreya/searching-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Searching Algorithms (C++ & Python)

C++ Python

Description

Highly optimized and performant search algorithms for binary search trees (BST), graphs, and arrays. Each algorithm is implemented in both C++ and Python and is accompanied with clear explanations of the underlying logic and performance-optimizing techniques, along with their applications.

Table of Contents

Arrays

  • Linear Search
  • Binary Search
  • Binary Search w/ Recursion
  • Binary Search w/ Duplicates
  • Ternary Search
  • Jump Search (for sorted arrays)
  • Exponential Search (for unbounded arrays)
  • Interpolation Search (for uniformly distributed sorted arrays)
  • Fibonacci Search

Binary Search Tree (BST)

  • Binary Search
  • Inserting a Node
  • Deleting a Node
  • Find Minimum Node
  • Find Maximum Node
  • Depth-First Search (DFS):
    • Pre-Order Traversal
    • In-Order Traversal
    • Post-Order Traversal
  • Breadth-First Search (BFS)
  • Find Successor/Predecessor
  • Balancing BST (e.g., AVL Tree, Red-Black Tree)

Graphs

General Graph Algorithms

  • Searching for a Specific Vertex
  • Depth-First Search (DFS)
    • Pre-Order Traversal
    • In-Order Traversal
    • Post-Order Traversal
  • Breadth-First Search (BFS)
  • Cycle Detection (for Cyclic Graphs)
  • Connected Components (using DFS/BFS)

Directed Graphs

  • DFS for Directed Graphs
  • Topological Sort (for Directed Acyclic Graphs)
  • Strongly Connected Components (Kosaraju’s/Tarjan's algorithms)

Weighted Graphs

  • Dijkstra's Algorithm (shortest path)
  • Bellman-Ford Algorithm (handles negative weights)
  • Floyd-Warshall Algorithm (for all-pairs shortest path)
  • A* Search Algorithm (heuristic-based)

Unweighted Graphs

  • BFS/DFS (for shortest path and traversal)

Special Cases (Might Not Do These)

  • Minimum Spanning Tree:
    • Prim's Algorithm
    • Kruskal's Algorithm
  • Bipartite Graph Check (using BFS/DFS)
  • Eulerian Path/Circuit
  • Hamiltonian Path

Additional

  • Trie Search (prefix-based searching)

Contributing

If you have suggestions to optimize an algorithm, identify any issues, or improve the documentation, please fork the repository and submit a pull request. Alternatively, you can also open an issue to start a discussion about the potential improvement.

About

Highly optimized & performant search algorithms for BSTs, graphs, and arrays, implemented in both C++ and Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages