Skip to content

Commit f039b39

Browse files
nadr0TornjV
authored andcommitted
all algorithms use mathjax for complexities (algorithm-visualizer#212)
1 parent 52dbc4c commit f039b39

File tree

54 files changed

+139
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+139
-145
lines changed

algorithm/backtracking/knight's_tour/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Knight’s tour problem": "A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.",
33
"Complexity": {
4-
"time": "Worst $$O(8^{N^{2}})$$",
5-
"space": "Worst $$O(N^2)$$"
4+
"time": "Worst $O(8^{N^{2}})$",
5+
"space": "Worst $O(N^2)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Knight%27s_tour'>Wikipedia</a>"

algorithm/backtracking/n_queens/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Searching"
66
],
77
"Complexity": {
8-
"time": "Worst $$O(N!)$$",
9-
"space": "Worst $$O(N)$$"
8+
"time": "Worst $O(N!)$",
9+
"space": "Worst $O(N)$"
1010
},
1111
"References": [
1212
"<a href='http://www.geeksforgeeks.org/backtracking-set-3-n-queen-problem/'>geeksforgeeks</a>"

algorithm/cryptography/affine_cipher/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"More complex Variations of Affine Cipher are used in practical cryptography"
66
],
77
"Complexity": {
8-
"time": "worst O(N), N = length of plain/cipher text",
9-
"space": "worst O(N), to create the new mapping (plain->cipher, cipher->plain)"
8+
"time": "worst $O(N)$, $N$ = length of plain/cipher text",
9+
"space": "worst $O(N)$, to create the new mapping (plain->cipher, cipher->plain)"
1010
},
1111
"References": [
1212
"<a href='http://practicalcryptography.com/ciphers/affine-cipher/'>Practicalcryptography</a>"

algorithm/dp/catalan_number/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"The number of ways to cut an n+2-sided convex polygon in a plane into triangles by connecting vertices with straight, non-intersecting lines is the nth Catalan number. This is the application in which Euler was interested."
77
],
88
"Complexity": {
9-
"time": " O(N<sup>2</sup>)",
10-
"space": "O(N)"
9+
"time": " $O(N^2)$",
10+
"space": "$O(N)$"
1111
},
1212
"References": [
1313
"<a href='https://en.wikipedia.org/wiki/Catalan_number'>Wikipedia</a>",
@@ -16,4 +16,4 @@
1616
"files": {
1717
"catalan_number": "Catalan Number"
1818
}
19-
}
19+
}

algorithm/dp/fibonacci/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Fibonacci Sequence": "Finding Fibonacci sequence using dynamic programming.",
33
"Complexity": {
4-
"time": "O(n)",
5-
"space": "O(n)"
4+
"time": "$O(n)$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Dynamic_programming#Fibonacci_sequence'>Wikipedia</a>"
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Integer Partition": "In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers.",
33
"Complexity": {
4-
"time": "O(n(log n))",
5-
"space": "O(n<sup>2</sup>)"
4+
"time": "$O(n(log \\, n))$",
5+
"space": "$O(n^2)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Partition_(number_theory)'>Wikipedia</a>"
99
],
1010
"files": {
1111
"basic": "Integer partition"
1212
}
13-
}
13+
}

algorithm/dp/knapsack_problem/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Knapsack Problem": "Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.",
33
"Complexity": {
4-
"time": "O(n<sup>2</sup>)",
5-
"space": "O(n<sup>2</sup>)"
4+
"time": "$O(n^2)$",
5+
"space": "$O(n^2)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Knapsack_problem'>Wikipedia</a>"
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Longest Common Subsequence": "The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences)." ,
33
"Complexity": {
4-
"time": "O(mn)",
5-
"space": "O(mn)"
4+
"time": "$O(m\\cdot n)$",
5+
"space": "$O(m\\cdot n)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Longest_common_subsequence_problem'>Wikipedia</a>"
99
],
1010
"files": {
1111
"basic": "Longest common subsequence"
1212
}
13-
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Longest Increasing Subsequence": "Find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order",
33
"Complexity": {
4-
"time": "O(n(log n))",
5-
"space": "O(n)"
4+
"time": "$O(n(log\\,n))$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Longest_increasing_subsequence'>Wikipedia</a>"
99
],
1010
"files": {
1111
"basic": "Longest increasing subsequence"
1212
}
13-
}
13+
}

algorithm/dp/longest_palindromic_subsequence/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Longest Palindromic Subsequence": "Find the length of the longest palindromic subsequence in a given sequence",
33
"Complexity": {
4-
"time": "O(n<sup>2</sup>)",
5-
"space": "O(n<sup>2</sup>)"
4+
"time": "$O(n^2)$",
5+
"space": "$O(n^2)$"
66
},
77
"References": [
88
"<a href='http://www.geeksforgeeks.org/dynamic-programming-set-12-longest-palindromic-subsequence/'>GeeksForGeeks</a>"

algorithm/dp/max_subarray/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Maximum Subarray": "Find the sum of the maximum Subarray in the given Array",
33
"Complexity": {
4-
"time": "O(n)",
5-
"space": "O(n)"
4+
"time": "$O(n)$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Maximum_subarray_problem'>Wikipedia</a>"
99
],
1010
"files": {
1111
"basic": "Maximum subarray"
1212
}
13-
}
13+
}

algorithm/dp/max_sum_path/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"Maximum Sum Path": "Finding the maximum sum in a path from (0, 0) to (N-1, M-1) when can only move to right or down",
33
"Complexity": {
4-
"time": "O(n)",
5-
"space": "O(n)"
4+
"time": "$O(n)$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
],
99
"files": {
1010
"basic": "Maximum sum path"
1111
}
12-
}
12+
}

algorithm/dp/pascal_triangle/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"Probability"
66
],
77
"Complexity": {
8-
"time": " O(N<sup>2</sup>)",
9-
"space": "O(N<sup>2</sup>)"
8+
"time": " $O(N^2)$",
9+
"space": "$O(N^2)$"
1010
},
1111
"References": [
1212
"<a href='https://en.wikipedia.org/wiki/Pascal%27s_triangle'>Wikipedia</a>"
1313
],
1414
"files": {
1515
"pascal_triangle": "Pascal's Triangle"
1616
}
17-
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Shortest Common Supersequence": "n computer science, the shortest common supersequence problem is a problem closely related to the longest common subsequence problem. Given two sequences X = < x1,...,xm > and Y = < y1,...,yn >, a sequence U = < u1,...,uk > is a common supersequence of X and Y if U is a supersequence of both X and Y. In other words, a shortest common supersequence of strings x and y is a shortest string z such that both x and y are subsequences of z." ,
33
"Complexity": {
4-
"time": "O(mn)",
5-
"space": "O(mn)"
4+
"time": "$O(m\\cdot n)$",
5+
"space": "$O(m\\cdot n)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Shortest_common_supersequence_problem'>Wikipedia</a>"
99
],
1010
"files": {
1111
"basic": "Shortest common supersequence"
1212
}
13-
}
13+
}

algorithm/dp/sliding_window/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"Sliding Window": "Finding the largest sum of three contiguous number",
33
"Complexity": {
4-
"time": "O(n)",
5-
"space": "O(n)"
4+
"time": "$O(n)$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
],
99
"files": {
1010
"basic": "Sliding window"
1111
}
12-
}
12+
}

algorithm/dp/ugly_numbers/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"Ugly Numbers": "Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence (1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …) shows the first 11 ugly numbers. By convention, 1 is included. The given code displays the first N ugly numbers.",
33
"Complexity": {
4-
"time": "O(n)",
5-
"space": "O(n)"
4+
"time": "$O(n)$",
5+
"space": "$O(n)$"
66
},
77
"References": [
88
"<a href='http://www.algorithmist.com/index.php/UVa_136'>Algorithmist</a>"
99
],
1010
"files": {
1111
"basic": "Ugly Numbers"
1212
}
13-
}
13+
}

algorithm/etc/magic_square/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Magic Square": "In recreational mathematics, a magic square is an arrangement of distinct numbers (i.e., each number is used once), usually integers, in a square grid, where the numbers in each row, and in each column, and the numbers in the main and secondary diagonals, all add up to the same number, called the magic constant. A magic square has the same number of rows as it has columns, and in conventional math notation, 'n' stands for the number of rows (and columns) it has. Thus, a magic square always contains n2 numbers, and its size (the number of rows [and columns] it has) is described as being of order n. A magic square that contains the integers from 1 to n2 is called a normal magic square. (The term magic square is also sometimes used to refer to any of various types of word squares.)",
33
"Complexity": {
4-
"time": " O(N<sup>2</sup>)",
5-
"space": "O(N<sup>2</sup>)"
4+
"time": " $O(N^2)$",
5+
"space": "$O(N^2)$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Magic_square'>Wikipedia</a>"

algorithm/graph_search/bellman_ford/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"Packet Routing - A variation of BF is used in the Distance vector Routing Protocol"
55
],
66
"Complexity": {
7-
"time": "worst O(|V|.|E|)",
8-
"space": "worst O(|V|)"
7+
"time": "worst $O(|V|\\cdot |E|)$",
8+
"space": "worst $O(|V|)$"
99
},
1010
"References": [
1111
"<a href='https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm'>Wikipedia</a>"

algorithm/graph_search/bfs/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"Construction of the failure function of the Aho-Corasick pattern matcher."
1111
],
1212
"Complexity": {
13-
"time": "worst O(|E|)",
14-
"space": "worst O(|V|)"
13+
"time": "worst $O(|E|)$",
14+
"space": "worst $O(|V|)$"
1515
},
1616
"References": [
1717
"<a href='https://en.wikipedia.org/wiki/Breadth-first_search'>Wikipedia</a>"
@@ -20,4 +20,4 @@
2020
"tree": "Searching a tree",
2121
"shortest_path": "Finding the shortest path"
2222
}
23-
}
23+
}

algorithm/graph_search/bridges/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"Finding vulnerabilities in Graphs and Electrical Circuits"
55
],
66
"Complexity": {
7-
"time": "worst Naive: O(|E|.(|V|+|E|)), Efficient: O(|V|+|E|)",
8-
"space": "worst O(|V|.|E|)"
7+
"time": "worst Naive: $O(|E| \\cdot (|V|+|E|))$, Efficient: $O(|V|+|E|)$",
8+
"space": "worst $O(|V| \\cdot |E|)$"
99
},
1010
"References": [
1111
"<a href='https://en.wikipedia.org/wiki/Bridge_(graph_theory)'>Wikipedia</a>"
@@ -14,4 +14,4 @@
1414
"naive": "Find all the bridges in an Undirected Graph",
1515
"efficient": "Efficiently find all the bridges in an Undirected Graph"
1616
}
17-
}
17+
}

algorithm/graph_search/dfs/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"Finding biconnectivity in graphs."
1515
],
1616
"Complexity": {
17-
"time": "worst O(|E|)",
18-
"space": "worst O(|V|)"
17+
"time": "worst $O(|E|)$",
18+
"space": "worst $O(|V|)$"
1919
},
2020
"References": [
2121
"<a href='https://en.wikipedia.org/wiki/Depth-first_search'>Wikipedia</a>"
@@ -27,4 +27,4 @@
2727
"shortest_path": "Finding the shortest path",
2828
"exploration": "Explore an undirected graph to see if it is connected"
2929
}
30-
}
30+
}

algorithm/graph_search/dijkstra/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"Ar."
55
],
66
"Complexity": {
7-
"time": "worst O(|V|<sup>2</sup>)",
8-
"space": "worst O(|V|)"
7+
"time": "worst $O(|V|^2)$",
8+
"space": "worst $O(|V|)$"
99
},
1010
"References": [
1111
"<a href='https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm'>Wikipedia</a>"
1212
],
1313
"files": {
1414
"shortest_path": "Finding the shortest path between two nodes"
1515
}
16-
}
16+
}

algorithm/graph_search/floyd_warshall/desc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
""
55
],
66
"Complexity": {
7-
"time": "worst O(|V|<sup>3</sup>)",
8-
"space": "worst O(|V|<sup>2</sup>)"
7+
"time": "worst $O(|V|^3)$",
8+
"space": "worst $O(|V|^2)$"
99
},
1010
"References": [
1111
"<a href='https://en.wikipedia.org/wiki/Floyd–Warshall_algorithm'>Wikipedia</a>"
1212
],
1313
"files": {
1414
"shortest_paths": "Finding the shortest path between all nodes"
1515
}
16-
}
16+
}

algorithm/graph_search/page_rank/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"Web Page Indexing for refining search results"
55
],
66
"Complexity": {
7-
"time": "worst O(|V|+|E|)",
8-
"space": "worst O(|V|)"
7+
"time": "worst $O(|V|+|E|)$",
8+
"space": "worst $O(|V|)$"
99
},
1010
"References": [
1111
"<a href='http://www.cs.princeton.edu/~chazelle/courses/BIB/pagerank.htm'>Princeton university</a>",

algorithm/graph_search/topological_sort/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"Data serialization"
99
],
1010
"Complexity": {
11-
"time": "worst O(|V|+|E|)",
12-
"space": "worst O(|V|)"
11+
"time": "worst $O(|V|+|E|)$",
12+
"space": "worst $O(|V|)$"
1313
},
1414
"References": [
1515
"<a href='http://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/'>GeeksForGeeks</a>",
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"Job Scheduling Algorithm": "An array of jobs along with their deadline and profit (if job completes within deadline) where every job takes single unit of time. Maximize total profit if only one job can be scheduled at a time.",
33
"Applications": [
4-
4+
55
],
66
"Complexity": {
7-
"time": " O(N<sup>2</sup>)",
8-
"space": "O(N)"
7+
"time": " $O(N^2)$",
8+
"space": "$O(N)$"
99
},
1010
"References": [
1111
"<a href='http://ocw.mit.edu/courses/civil-and-environmental-engineering/1-204-computer-algorithms-in-systems-engineering-spring-2010/lecture-notes/MIT1_204S10_lec10.pdf'>mit.edu</a>"
1212
],
1313
"files": {
1414
"job_scheduling": "Job Scheduling Algorithm"
1515
}
16-
}
16+
}

0 commit comments

Comments
 (0)