Skip to content

Commit

Permalink
tagged algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
elimelt committed Jan 1, 2025
1 parent 2e2d02a commit 47c9bb0
Show file tree
Hide file tree
Showing 169 changed files with 1,752 additions and 140 deletions.
10 changes: 10 additions & 0 deletions algorithms/BFS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---
title: Breadth First Search Algorithm Implementation and Analysis
category: algorithms
tags:
- graph-traversal
- shortest-paths
- graph-theory
- complexity-analysis
description: A comprehensive explanation of the Breadth First Search (BFS) algorithm, including implementation, complexity analysis, and mathematical proofs. The document covers the algorithm's properties for finding shortest paths in graphs and includes Python implementations with detailed theoretical foundations and lemmas about level ordering.
---
# Breadth First Search

Completely explore the vertices of a graph in order of their distance from the starting node.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/DAGs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Topological Ordering and Properties of Directed Acyclic Graphs
category: algorithms
tags:
- graph theory
- topological sorting
- directed acyclic graphs
- proofs
description: A technical exploration of Directed Acyclic Graphs (DAGs) focusing on their topological ordering properties and fundamental lemmas. The document includes mathematical proofs of key DAG properties and presents a Python implementation of the topological sorting algorithm.
---

# Directed Acyclic Graphs (DAGs)

DAGs are pretty self explanatory, but their use cases are vast.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/DFS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Depth First Search Algorithm and Tree Properties
category: algorithms
tags:
- graph theory
- depth first search
- spanning trees
- graph traversal
description: A technical explanation of Depth First Search (DFS) algorithm and its tree properties, including both recursive and iterative implementations. The document covers key properties of DFS trees, including the ancestor-descendant relationship of non-tree edges, and includes a formal lemma and proof about DFS tree characteristics.
---

# Depth First Search (DFS)

Running DFS on a graph produces a DFS tree (or depth-first spanning-tree). The DFS tree contains all the vertices of the graph and the edges of the DFS tree are a subset of the edges of the original graph.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/approximation-algorithms.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Approximation Algorithms
category: algorithms
tags:
- approximation
- algorithms
- vertex cover
- set cover
description: A survey of approximation algorithms, including the 2-approximation for vertex cover and the log(n) approximation for set cover.
---

# Approximation Algorithms

When faced with a problem that can be reduced to some NP-Complete problem, you (most probably) cannot generally solve it in polynomial time. For example:
Expand Down
11 changes: 11 additions & 0 deletions algorithms/bipartite-graphs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Bipartite Graphs Properties, Proofs, and Detection Algorithm
category: Graph Theory
tags:
- bipartite graphs
- graph coloring
- odd cycles
- breadth-first search
description: A comprehensive overview of bipartite graphs, including their formal definition and key properties related to vertex coloring and odd-length cycles. The document presents important lemmas about the relationship between bipartite graphs and odd cycles, along with proofs using BFS layer analysis for bipartite graph detection.
---

# Bipartite Graphs

- **Definition**: An undirected graph $G = (V, E)$ is bipartite if there exists a partition of $V$ into two sets $V_1$ and $V_2$ such that every edge in $E$ has one endpoint in $V_1$ and the other in $V_2$.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/connected-components.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Finding Connected Components in Undirected Graphs Using BFS/DFS
category: algorithms
tags:
- graph theory
- connected components
- breadth-first search
- depth-first search
description: Explains how to partition an undirected graph into connected components using BFS or DFS algorithms in O(|V| + |E|) time complexity. Includes Python implementation using adjacency lists and demonstrates how to create a data structure that enables O(1) time queries for path existence between vertices.
---

# Connected Components

Given an undirected graph $G = (V, E)$, you can find partition $V$ into sets of connected components $C_1, C_2, \ldots$ in $O(|V| + |E|)$ using breadth-first search (BFS) or depth-first search (DFS).
Expand Down
11 changes: 11 additions & 0 deletions algorithms/divide-and-conquer.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Divide and Conquer Algorithm Analysis with Implementation Examples
category: algorithms
tags:
- divide-and-conquer
- algorithmic-complexity
- recursive-algorithms
- computational-geometry
description: A comprehensive examination of divide and conquer algorithmic strategies, focusing on their implementation and analysis. The document covers theoretical foundations with mathematical proofs, practical examples including bisection method and closest pair problem, and includes Python implementations demonstrating these concepts.
---

# Divide and Conquer

Reduce problem to multiple sub-problems. While in induction, you typically only reduce your problem size by 1, with divide and conquer it is more common to reduce to some constant fraction of your original problem size. After recursively solving each sub-problem, merge the solutions.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/dynamic-programming.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Dynamic Programming Algorithms and Problem Solutions Guide
category: algorithms
tags:
- dynamic-programming
- optimization
- algorithm-analysis
- problem-solving
description: A comprehensive guide covering various dynamic programming algorithms and their implementations, including knapsack, sequence alignment, and tree-based problems. Includes detailed explanations of problem-solving approaches, correctness proofs, and runtime analysis for each algorithm, with practical Python implementations.
---

# Dynamic Programming

**Dynamic Programming** is an algorithmic paradigm where you break up a problem into a series of **overlapping** sub-problems, building up solutions to progressively larger subproblems until the original answer is obtained. The key efficiency of DP is to **memoize** the answers to sub problems, often yielding a polynomial time algorithm.
Expand Down
11 changes: 11 additions & 0 deletions algorithms/graphs-intro.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Introduction to Undirected Graphs and Their Properties
category: Graph Theory
tags:
- graph fundamentals
- graph representation
- graph properties
- data structures
description: A comprehensive introduction to undirected graphs covering fundamental concepts, properties, and storage methods. The document explains key terminology, proves important theorems about degree sums and odd vertices, and compares adjacency matrix and list representations with their respective time and space complexities.
---

# Graphs Introduction

## Undirected Graphs
Expand Down
12 changes: 12 additions & 0 deletions algorithms/greedy-algorithms.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
---
title: Greedy Algorithms for Interval Scheduling and Partitioning
category: Algorithm Analysis
tags:
- Greedy Algorithms
- Interval Scheduling
- Interval Partitioning
- Proof Techniques
- Optimization
description: This document explores greedy algorithms for interval scheduling and partitioning problems. It provides detailed explanations of the algorithms, including Python implementations, and presents rigorous proofs of correctness using techniques such as "Greedy Stays Ahead" and exchange arguments.
---

# Greedy Algorithms

Choose the most attractive choice at each step, and hope that this will lead to the optimal solution. Proofs of correctness are particularly important for greedy algorithms.
Expand Down
13 changes: 13 additions & 0 deletions algorithms/induction.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
---
title: Mathematical Induction and Pigeonhole Principle Proofs
category: Mathematics
tags:
- Induction
- Pigeonhole Principle
- Proof Techniques
- Number Theory
- Combinatorics
description: This document presents detailed proofs using mathematical induction and the pigeonhole principle. It demonstrates the inductive proof for the sum of natural numbers and provides a step-by-step proof of the pigeonhole principle, emphasizing the general approach to inductive reasoning in mathematics.
---


# Induction

Prove...
Expand Down
12 changes: 12 additions & 0 deletions algorithms/linear-programming.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
---
title: Linear Programming Fundamentals and Applications in Optimization
category: Operations Research
tags:
- Linear Systems
- Linear Programs
- Optimization
- Standard Form
- Application Examples
description: This document provides a comprehensive overview of linear programming, covering linear systems, linear programs, and their standard forms. It explains key concepts such as hyperplanes, polytopes, and convex sets, and demonstrates how to transform various optimization problems into linear programs. The document also explores practical applications of linear programming in areas like max-flow and weighted vertex cover problems.
---

# Linear Programming

## Linear Systems
Expand Down
12 changes: 12 additions & 0 deletions algorithms/network-flows.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
---
title: Network Flow Algorithms and Applications in Graph Theory
category: Graph Theory
tags:
- Max Flow Min Cut
- Ford-Fulkerson Algorithm
- Bipartite Matching
- Vertex Cover
- Independent Set
description: Comprehensive overview of network flow algorithms, including Max Flow/Min Cut and Ford-Fulkerson. Covers applications in bipartite matching, vertex cover, and independent set problems. Includes proofs, algorithms, and problem-solving techniques for graph theory concepts.
---

# Network Flow - Max Flow and Min Cut

## Max Flow/Min Cut
Expand Down
11 changes: 11 additions & 0 deletions algorithms/runtime.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: Measuring Algorithm Efficiency with Asymptotic Notation
category: Computer Science
tags:
- Algorithm Analysis
- Time Complexity
- Asymptotic Notation
- Efficiency Bounds
description: This document introduces methods for measuring algorithm efficiency using asymptotic notation. It defines O-notation, Omega-notation, and Theta-notation, and provides common efficiency bounds for various function types, emphasizing the importance of polynomial-time algorithms in practical computing.
---

# Measuring Efficiency

Time is roughly proportional to the number of operations performed. Generally, this holds for simple operations. As a side note, you should avoid hashing.
Expand Down
9 changes: 0 additions & 9 deletions algorithms/tmp.md

This file was deleted.

12 changes: 12 additions & 0 deletions algorithms/tree-intro.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
---
title: Tree Properties and Proof of Edge Count
category: Graph Theory
tags:
- Trees
- Acyclic Graphs
- Connected Graphs
- Induction Proofs
- Graph Properties
description: This document explores the fundamental properties of trees in graph theory. It provides a proof by induction that a tree with n vertices has n-1 edges and outlines three key properties of trees, demonstrating their interconnected nature.
---

# Trees

### Lemma: acyclic and connected
Expand Down
1 change: 1 addition & 0 deletions site/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<body>
<nav>
<a href="/index.html">Home</a>
<a href="/categories/index.html">Categories</a>
</nav>
<main>
<div class="breadcrumbs">
Expand Down
21 changes: 15 additions & 6 deletions site/algorithms/BFS.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bfs</title>
<title>Breadth First Search Algorithm Implementation and Analysis</title>

<style>
:root {
Expand Down Expand Up @@ -170,18 +170,27 @@
<body>
<nav>
<a href="/index.html">Home</a>
<a href="/categories/index.html">Categories</a>
</nav>
<main>
<div class="breadcrumbs">
<a href="/index.html">Home</a> » Bfs
<a href="/index.html">Home</a> » <a href="/categories/algorithms.html">algorithms</a> » Breadth First Search Algorithm Implementation and Analysis
</div>
<h1>Bfs</h1>
<h1>Breadth First Search Algorithm Implementation and Analysis</h1>
<div class="meta">
<span>Last modified: 2024-04-03</span>

<span>Last modified: 2025-01-01</span>
<span>Category: <a href="/categories/algorithms.html">algorithms</a></span>
</div>
<div class="content">
<h1 id="breadth-first-search">Breadth First Search</h1>
<ul>
<li>graph-traversal</li>
<li>shortest-paths</li>
<li>graph-theory</li>
<li>complexity-analysis
description: A comprehensive explanation of the Breadth First Search (BFS) algorithm, including implementation, complexity analysis, and mathematical proofs. The document covers the algorithm's properties for finding shortest paths in graphs and includes Python implementations with detailed theoretical foundations and lemmas about level ordering.</li>
</ul>
<hr />
<h1 id="breadth-first-search">Breadth First Search</h1>
<p>Completely explore the vertices of a graph in order of their distance from the starting node.</p>
<p>There are three states of a vertex in BFS:
- <strong>Undiscovered</strong>: The vertex has not been seen yet.
Expand Down
21 changes: 15 additions & 6 deletions site/algorithms/DAGs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dags</title>
<title>Topological Ordering and Properties of Directed Acyclic Graphs</title>

<style>
:root {
Expand Down Expand Up @@ -170,18 +170,27 @@
<body>
<nav>
<a href="/index.html">Home</a>
<a href="/categories/index.html">Categories</a>
</nav>
<main>
<div class="breadcrumbs">
<a href="/index.html">Home</a> » Dags
<a href="/index.html">Home</a> » <a href="/categories/algorithms.html">algorithms</a> » Topological Ordering and Properties of Directed Acyclic Graphs
</div>
<h1>Dags</h1>
<h1>Topological Ordering and Properties of Directed Acyclic Graphs</h1>
<div class="meta">
<span>Last modified: 2024-04-14</span>

<span>Last modified: 2025-01-01</span>
<span>Category: <a href="/categories/algorithms.html">algorithms</a></span>
</div>
<div class="content">
<h1 id="directed-acyclic-graphs-dags">Directed Acyclic Graphs (DAGs)</h1>
<ul>
<li>graph theory</li>
<li>topological sorting</li>
<li>directed acyclic graphs</li>
<li>proofs
description: A technical exploration of Directed Acyclic Graphs (DAGs) focusing on their topological ordering properties and fundamental lemmas. The document includes mathematical proofs of key DAG properties and presents a Python implementation of the topological sorting algorithm.</li>
</ul>
<hr />
<h1 id="directed-acyclic-graphs-dags">Directed Acyclic Graphs (DAGs)</h1>
<p>DAGs are pretty self explanatory, but their use cases are vast.</p>
<h2 id="topological-orderings">Topological Orderings</h2>
<p>A <strong>topological ordering</strong> of a directed graph $G = (V, E)$ is a linear ordering of all its vertices such that for every directed edge $(v_i, v_j) \in E$, $v_i$ comes before $v_j$ in the ordering if $v_i &lt; v_j$.</p>
Expand Down
21 changes: 15 additions & 6 deletions site/algorithms/DFS.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dfs</title>
<title>Depth First Search Algorithm and Tree Properties</title>

<style>
:root {
Expand Down Expand Up @@ -170,18 +170,27 @@
<body>
<nav>
<a href="/index.html">Home</a>
<a href="/categories/index.html">Categories</a>
</nav>
<main>
<div class="breadcrumbs">
<a href="/index.html">Home</a> » Dfs
<a href="/index.html">Home</a> » <a href="/categories/algorithms.html">algorithms</a> » Depth First Search Algorithm and Tree Properties
</div>
<h1>Dfs</h1>
<h1>Depth First Search Algorithm and Tree Properties</h1>
<div class="meta">
<span>Last modified: 2024-04-13</span>

<span>Last modified: 2025-01-01</span>
<span>Category: <a href="/categories/algorithms.html">algorithms</a></span>
</div>
<div class="content">
<h1 id="depth-first-search-dfs">Depth First Search (DFS)</h1>
<ul>
<li>graph theory</li>
<li>depth first search</li>
<li>spanning trees</li>
<li>graph traversal
description: A technical explanation of Depth First Search (DFS) algorithm and its tree properties, including both recursive and iterative implementations. The document covers key properties of DFS trees, including the ancestor-descendant relationship of non-tree edges, and includes a formal lemma and proof about DFS tree characteristics.</li>
</ul>
<hr />
<h1 id="depth-first-search-dfs">Depth First Search (DFS)</h1>
<p>Running DFS on a graph produces a DFS tree (or depth-first spanning-tree). The DFS tree contains all the vertices of the graph and the edges of the DFS tree are a subset of the edges of the original graph.</p>
<p>Unlike the BFS tree, DFS trees aren't minimum depth, and its levels don't really tell you much. However, the property holds that sub-trees of a DFS tree must not contain any edges connecting them.</p>
<p><strong>Lemma</strong>: For a DFS tree of graph $G = (V, E)$ $T = (V_t, E_t)$, $\forall e = (x, y) \in E$, if $e \notin E_t$, then one of $x$ or $y$ is an ancestor of the other in the tree.</p>
Expand Down
Loading

0 comments on commit 47c9bb0

Please sign in to comment.