Skip to content

Commit

Permalink
auto
Browse files Browse the repository at this point in the history
  • Loading branch information
elimelt committed Jan 1, 2025
1 parent e991a35 commit ef61cd0
Show file tree
Hide file tree
Showing 78 changed files with 9,408 additions and 226 deletions.
6 changes: 1 addition & 5 deletions algorithms/DFS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Depth First Search Algorithm and Tree Properties
category: algorithms
tags:
- graph theory
- depth first search
- spanning trees
- graph traversal
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/approximation-algorithms.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Approximation Algorithms
category: algorithms
tags:
- approximation
- algorithms
- vertex cover
- set cover
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/bipartite-graphs.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Bipartite Graphs Properties, Proofs, and Detection Algorithm
category: Graph Theory
tags:
- bipartite graphs
- graph coloring
- odd cycles
- breadth-first search
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/connected-components.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Finding Connected Components in Undirected Graphs Using BFS/DFS
category: algorithms
tags:
- graph theory
- connected components
- breadth-first search
- depth-first search
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/dynamic-programming.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Dynamic Programming Algorithms and Problem Solutions Guide
category: algorithms
tags:
- dynamic-programming
- optimization
- algorithm-analysis
- problem-solving
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/graphs-intro.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Introduction to Undirected Graphs and Their Properties
category: Graph Theory
tags:
- graph fundamentals
- graph representation
- graph properties
- data structures
tags: graph, 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.
---

Expand Down
27 changes: 11 additions & 16 deletions algorithms/greedy-algorithms.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
---
title: Greedy Algorithms for Interval Scheduling and Partitioning
category: Algorithm Analysis
tags:
- Greedy Algorithms
- Interval Scheduling
- Interval Partitioning
- Proof Techniques
- Optimization
tags: algorithms, interval, scheduling, partitioning, greedy-algorithms
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
# 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.

## Interval Scheduling
## Interval Scheduling

Job $j$ starts at $s(j)$ and finishes at $f(j)$. Two jobs are compatible if they don't overlap. The goal is to schedule as many jobs as possible without overlapping.
Job $j$ starts at $s(j)$ and finishes at $f(j)$. Two jobs are compatible if they don't overlap. The goal is to schedule as many jobs as possible without overlapping.

Start by sorting the jobs with $f(j)$, and iterate over the jobs in order and choose as many jobs as you can.

Expand All @@ -36,17 +31,17 @@ def interval_scheduling(jobs):

Suppose the above algorithm has chosen jobs $f(i_1) \le f(i_2) \le \ldots \le f(i_k)$, and suppose $f(j_1) \le f(j_2) \le \ldots \le f(j_m)$.

*Goal:* $m \le k$
_Goal:_ $m \le k$

*Lemma*: $\forall r$, $f(i_r) \le f(j_r)$
_Lemma_: $\forall r$, $f(i_r) \le f(j_r)$

*Proof*: Induction, $P(r) := f(i_r) \le f(j_r)$
_Proof_: Induction, $P(r) := f(i_r) \le f(j_r)$

*Base Case*: $P(1)$. $i_1$ has the smallest finishing time.
_Base Case_: $P(1)$. $i_1$ has the smallest finishing time.

*IH*: Assume $P(r - 1)$
_IH_: Assume $P(r - 1)$

*IS*: Goal $P(r)$
_IS_: Goal $P(r)$

Applying $P(r - 1)$, and using the fact that both sets of jobs chosen are non-overlapping within themselves, we have...

Expand Down Expand Up @@ -99,6 +94,6 @@ def partition_intervals(I: list[tuple[int, int]]):

Let $d$ be the number of classrooms the greedy algorithm uses. Classroom $d$ is then allocated because we needed to schedule a job, $j$, that is incompatible with all $d - 1$ previously allocated classrooms.

Since we sorted by start time, all these incompatible jobs must have started before $s(j)$, and thus we have $d$ lectures overlapping at time $s(j) + \epsilon$, so our maximum depth is $\ge d$.
Since we sorted by start time, all these incompatible jobs must have started before $s(j)$, and thus we have $d$ lectures overlapping at time $s(j) + \epsilon$, so our maximum depth is $\ge d$.

Since we have that the optimal solution must schedule at least depth number of classrooms, we have that the greedy algorithm is optimal.
7 changes: 1 addition & 6 deletions algorithms/induction.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
title: Mathematical Induction and Pigeonhole Principle Proofs
category: Mathematics
tags:
- Induction
- Pigeonhole Principle
- Proof Techniques
- Number Theory
- Combinatorics
tags: induction, pigeonhole principle, proof techniques
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.
---

Expand Down
7 changes: 1 addition & 6 deletions algorithms/linear-programming.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
title: Linear Programming Fundamentals and Applications in Optimization
category: Operations Research
tags:
- Linear Systems
- Linear Programs
- Optimization
- Standard Form
- Application Examples
tags: linear systems, linear programs, optimization
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.
---

Expand Down
7 changes: 1 addition & 6 deletions algorithms/network-flows.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
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
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.
---

Expand Down
6 changes: 1 addition & 5 deletions algorithms/runtime.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
title: Measuring Algorithm Efficiency with Asymptotic Notation
category: Computer Science
tags:
- Algorithm Analysis
- Time Complexity
- Asymptotic Notation
- Efficiency Bounds
tags: algorithm, time complexity, asymptotic notation, efficiency
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.
---

Expand Down
7 changes: 7 additions & 0 deletions algorithms/stable-matching.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---
title: Stable Matching Algorithms and Proofs in Computer Science
category: Algorithm Analysis
tags: matching, stable matching, gale-shapley, proof techniques, complexity analysis, optimization
description: This document provides a comprehensive overview of stable matching algorithms, focusing on the Gale-Shapley algorithm and its properties. It includes detailed proofs of correctness, complexity analysis, and discussions on optimal assignments for companies and applicants. The document also explores related problems like the Stable Roommate Problem.
---

# Stable Matching

Given a list of $n$ companies $c_1, c_2, \ldots, c_n$, and a list of students $s_1, s_2, \ldots, s_n$, each company ranks the students in order of preference, and each student ranks the companies in order of preference.
Expand Down
7 changes: 1 addition & 6 deletions algorithms/tree-intro.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
title: Tree Properties and Proof of Edge Count
category: Graph Theory
tags:
- Trees
- Acyclic Graphs
- Connected Graphs
- Induction Proofs
- Graph Properties
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.
---

Expand Down
14 changes: 3 additions & 11 deletions site/algorithms/DFS.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Depth First Search Algorithm and Tree Properties</title>

<meta name="description" content="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.">
<style>
:root {
--text-color: #1a1a1a;
Expand Down Expand Up @@ -183,15 +183,7 @@ <h1>Depth First Search Algorithm and Tree Properties</h1>
<span>Category: <a href="/categories/algorithms.html">algorithms</a></span>
</div>
<div class="content">
<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>
<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 Expand Up @@ -221,7 +213,7 @@ <h2 id="properties-of-dfs-spanning-trees">Properties of DFS Spanning Trees</h2>
<p>DFS visits every vertex within the starting vertex's connected component, so you can use it to find all connected components of a graph similar to BFS.</p>
<p>However, unlike BFS, the DFS tree has the property that every non-tree edge joins a vertex to one of its ancestors/decedents in the tree. We can thus still use DFS to find cycles in a graph.</p>
</div>

<div class='tags'>Tags: <a href="/tags/depth%20first%20search.html">depth first search</a>, <a href="/tags/graph%20theory.html">graph theory</a>, <a href="/tags/graph%20traversal.html">graph traversal</a>, <a href="/tags/spanning%20trees.html">spanning trees</a></div>
</main>
</body>
</html>
2 changes: 1 addition & 1 deletion site/algorithms/approximation-algorithms.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ <h3 id="logn-approximation-for-set-cover">log(n) approximation for Set Cover</h3
<strong>Algorithm</strong>: While there are remaining elements, choose the set that maximizes the number of new elements covered.</p>
<p>If the optimal solution has $k$ sets, this algorithm always selects at most $k log(n)$ sets. This is because there is at least a set that covers $\frac{1}{k}$ of the remaining elements, so after $t$ steps we have $ \le n(1 - \frac{1}{k})^t \le n \cdot e^{-\frac{t}{k}}$ remaining elements. Therefore, after $t = k\ln(n)$ steps, we have $&lt; 1$ uncovered element remaining.</p>
</div>

<div class='tags'>Tags: <a href="/tags/algorithms.html">algorithms</a>, <a href="/tags/approximation.html">approximation</a>, <a href="/tags/set%20cover.html">set cover</a>, <a href="/tags/vertex%20cover.html">vertex cover</a></div>
</main>
</body>
</html>
14 changes: 3 additions & 11 deletions site/algorithms/bipartite-graphs.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bipartite Graphs Properties, Proofs, and Detection Algorithm</title>

<meta name="description" content="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.">
<style>
:root {
--text-color: #1a1a1a;
Expand Down Expand Up @@ -183,15 +183,7 @@ <h1>Bipartite Graphs Properties, Proofs, and Detection Algorithm</h1>
<span>Category: <a href="/categories/graph%20theory.html">Graph Theory</a></span>
</div>
<div class="content">
<ul>
<li>bipartite graphs</li>
<li>graph coloring</li>
<li>odd cycles</li>
<li>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.</li>
</ul>
<hr />
<h1 id="bipartite-graphs">Bipartite Graphs</h1>
<h1 id="bipartite-graphs">Bipartite Graphs</h1>
<ul>
<li><strong>Definition</strong>: 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$.</li>
<li><strong>Applications</strong>:</li>
Expand All @@ -211,7 +203,7 @@ <h2 id="odd-length-cycles">Odd-Length Cycles</h2>
<h2 id="algorithm">Algorithm</h2>
<p><strong>Problem</strong>: Given a graph $G$, output <code>true</code> if it is bipartite, <code>false</code> otherwise.</p>
</div>

<div class='tags'>Tags: <a href="/tags/bipartite%20graphs.html">bipartite graphs</a>, <a href="/tags/breadth-first%20search.html">breadth-first search</a>, <a href="/tags/graph%20coloring.html">graph coloring</a>, <a href="/tags/odd%20cycles.html">odd cycles</a></div>
</main>
</body>
</html>
14 changes: 3 additions & 11 deletions site/algorithms/connected-components.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Finding Connected Components in Undirected Graphs Using BFS/DFS</title>

<meta name="description" content="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.">
<style>
:root {
--text-color: #1a1a1a;
Expand Down Expand Up @@ -183,15 +183,7 @@ <h1>Finding Connected Components in Undirected Graphs Using BFS/DFS</h1>
<span>Category: <a href="/categories/algorithms.html">algorithms</a></span>
</div>
<div class="content">
<ul>
<li>graph theory</li>
<li>connected components</li>
<li>breadth-first search</li>
<li>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.</li>
</ul>
<hr />
<h1 id="connected-components">Connected Components</h1>
<h1 id="connected-components">Connected Components</h1>
<p>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).</p>
<p>In other words, we can create a data structure from $G$ such that given two vertices $u, v \in V$, we we answer whether there exists a path from $u \to v$ in $O(1)$ time and $O(|V|)$ space.</p>
<p>The basic idea is to run a BFS/DFS starting at every vertex, and to assign a label to each vertex we visit during this traversal. We can use an array (if vertices are numbered) or hash map to store the vertex to component set mapping $V \to C_i$</p>
Expand Down Expand Up @@ -234,7 +226,7 @@ <h1 id="connected-components">Connected Components</h1>
<h2 id="strategy-for-unconnected-graph">Strategy for Unconnected Graph</h2>
<p>In general, if you are solving a graph problem you should first assume your graph is fully connected, and then after you've found a solution for connected graphs, you can run your algorithm on all the connected components of your graph.</p>
</div>

<div class='tags'>Tags: <a href="/tags/breadth-first%20search.html">breadth-first search</a>, <a href="/tags/connected%20components.html">connected components</a>, <a href="/tags/depth-first%20search.html">depth-first search</a>, <a href="/tags/graph%20theory.html">graph theory</a></div>
</main>
</body>
</html>
Loading

0 comments on commit ef61cd0

Please sign in to comment.