Advanced Markdown Features with LaTeX Support
Mathematical Expressions
Inline Math
You can include inline mathematical expressions like $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ within text.
The area of a circle is $A = \pi r^2$ where $r$ is the radius.
Display Math
For larger expressions, use display mode:
$$ \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi} $$
$$ \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} $$
Matrix Examples
$$ \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix} $$
Algorithms and Equations
The Big-O notation for time complexity:
$$ O(f(n)) = \{g(n) : \exists c > 0, n_0 \geq 0 \text{ such that } 0 \leq g(n) \leq cf(n) \text{ for all } n \geq n_0\} $$
Advanced Formatting
Tables
Algorithm | Best Case | Average Case | Worst Case | Space Complexity |
---|---|---|---|---|
Quick Sort | $O(n \log n)$ | $O(n \log n)$ | $O(n^2)$ | $O(\log n)$ |
Merge Sort | $O(n \log n)$ | $O(n \log n)$ | $O(n \log n)$ | $O(n)$ |
Heap Sort | $O(n \log n)$ | $O(n \log n)$ | $O(n \log n)$ | $O(1)$ |
Code Blocks with Syntax Highlighting
#include <iostream>
#include <vector>
#include <algorithm>
class BinarySearch {
public:
static int search(const std::vector<int>& arr, int target) {
int left = 0, right = arr.size() - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == target) {
return mid;
} else if (arr[mid] < target) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return -1; // Element not found
}
};
def fibonacci(n):
"""Calculate the nth Fibonacci number using dynamic programming"""
if n <= 1:
return n
dp = [0] * (n + 1)
dp[1] = 1
for i in range(2, n + 1):
dp[i] = dp[i-1] + dp[i-2]
return dp[n]
# Time complexity: O(n), Space complexity: O(n)
Blockquotes
Important Note: Always consider the time and space complexity of your algorithms.
A well-optimized algorithm can make the difference between a solution that works for small inputs and one that scales to handle large datasets efficiently.
Definition Lists
Algorithm : A step-by-step procedure for solving a problem or completing a task.
Data Structure : A way of organizing and storing data so that it can be accessed and modified efficiently.
Time Complexity : A computational measure that describes the amount of time an algorithm takes to run as a function of the input size.
Nested Lists with Math
-
Sorting Algorithms
- Comparison-based sorts:
- Bubble Sort: $O(n^2)$ average and worst case
- Quick Sort: $O(n \log n)$ average, $O(n^2)$ worst case
- Merge Sort: $O(n \log n)$ guaranteed
- Non-comparison sorts:
- Counting Sort: $O(n + k)$ where $k$ is the range
- Radix Sort: $O(d \cdot (n + k))$ where $d$ is digits
- Comparison-based sorts:
-
Graph Algorithms
- Shortest Path:
- Dijkstra's Algorithm: $O((V + E) \log V)$ with binary heap
- Bellman-Ford: $O(VE)$ - handles negative weights
- Minimum Spanning Tree:
- Kruskal's: $O(E \log E)$
- Prim's: $O(E \log V)$
- Shortest Path:
Mathematical Proofs
Theorem: The time complexity of binary search is $O(\log n)$.
Proof: Let $T(n)$ be the time complexity for searching in an array of size $n$.
In each step, we eliminate half of the remaining elements:
- After 1 comparison: $\frac{n}{2}$ elements remain
- After 2 comparisons: $\frac{n}{4}$ elements remain
- After $k$ comparisons: $\frac{n}{2^k}$ elements remain
We stop when $\frac{n}{2^k} = 1$, which gives us $k = \log_2 n$.
Therefore, $T(n) = O(\log n)$. â–¡
Chemical Formulas (Using LaTeX)
Water molecule: $\text{H}_2\text{O}$
Photosynthesis reaction: $$6\text{CO}_2 + 6\text{H}_2\text{O} + \text{light energy} \rightarrow \text{C}_6\text{H}_{12}\text{O}_6 + 6\text{O}_2$$
Complex Mathematical Expressions
Fourier Transform: $$\mathcal{F}\{f(t)\} = \int_{-\infty}^{\infty} f(t) e^{-2\pi i \xi t} dt$$
Taylor Series: $$f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n$$
Probability Density Function (Normal Distribution): $$f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}$$
Links and Images
For more information, visit GitHub or check out the official documentation.
You can also include images (this would work if you had an image file):
This demonstrates the enhanced markdown capabilities with full LaTeX support, advanced formatting, and syntax highlighting.