api: YAML JSON TOON Database version: 1.0.0 format: toon category: id: 390 slug: algorithms name: Algorithms description: "Classic algorithms, strategies, and complexity." icon: cpu created_at: 1783090350 dataset_count: 7 topic: overview: "Algorithm reference data is organized by design strategy rather than by application: searching and sorting, dynamic programming, greedy methods, backtracking and graph traversal, topped by the complexity classes that say which problems are efficiently solvable at all. An algorithm entry gives its idea and its cost, and the cost is the part that decides whether it is usable: an O(n log n) sort handles millions of items, an exponential search does not. The recurring skill is recognizing the structure of a problem (overlapping subproblems, a greedy-choice property, a need to explore all possibilities) and picking the matching strategy." key_ideas[7]{term,meaning}: Time and space complexity,"How running time and memory grow with input size, in Big-O terms. The same problem can have algorithms with very different growth rates." Divide and conquer,"Split a problem into smaller independent parts, solve them and combine the results. Merge sort and binary search are examples." Dynamic programming,Solve a problem with overlapping subproblems by storing the results of subproblems so each is computed once. Greedy algorithm,Make the locally best choice at each step. It is correct only when the problem has the greedy-choice property. Backtracking,Build a solution step by step and abandon a partial solution as soon as it cannot lead to a valid one. P versus NP,P is the class of problems solvable in polynomial time; NP those whose solutions can be verified in polynomial time. Whether they are equal is open. Stable sort,"A sort that keeps equal elements in their original order, which matters when sorting by several keys in turn." pitfalls[4]: "Choosing an algorithm by its best-case bound. Quicksort's worst case is O(n^2) and linear search's best case is O(1), but average and worst cases decide the experience.",Applying a greedy method without proving it correct; many problems that look greedy are not (the 0/1 knapsack).,"Treating Big-O as a speed measurement. It compares growth rates, not the time of one run on one machine.","Assuming NP-hard means impossible. Approximation, heuristics and exact methods on small instances are often practical." agent_tips[3]: "State the input assumptions (sorted, non-negative weights, bounded range) when recommending an algorithm.","Explain the key idea in one sentence, give the complexity and mention a common library implementation.","For optimization problems, say whether the algorithm is exact or approximate." start_with[2]: sorting-algorithms,complexity-classes datasets[7]{id,slug,title,description,tags,view_count,created_at,entry_count,summary}: 2736,backtracking-algorithms,Backtracking Algorithms,Algorithms that explore candidates and abandon partial solutions.,"algorithms,backtracking,recursion",48,1793403093,12,"Classic problems solved by backtracking: N-Queens, Sudoku, subset sum, graph coloring, Hamiltonian cycles and maze solving, extended with permutations, combination sum, word search, the knight's tour, palindrome partitioning and generating parentheses." 2754,complexity-classes,Complexity Classes,Key computational complexity classes and the problems they contain.,"algorithms,complexity,p-vs-np,computability",40,1793403093,13,"The principal computational complexity classes with a description and examples: P, NP, NP-complete, NP-hard, BPP, L and PSPACE, plus co-NP, NL, EXPTIME, BQP, #P and ZPP." 2784,dynamic-programming-patterns,Dynamic Programming Patterns,Classic problems solved with dynamic programming.,"algorithms,dynamic-programming,optimization",49,1793403093,15,"Classic dynamic-programming problems: Fibonacci, 0/1 knapsack, longest common subsequence, longest increasing subsequence, coin change, matrix chain multiplication, edit distance and maximum subarray, extended with rod cutting, longest palindromic subsequence, partition, house robber, word break, unique paths and egg dropping." 2803,graph-traversal-algorithms,Graph Traversal Algorithms,Fundamental algorithms for navigating graphs.,"algorithms,graphs,traversal",47,1793403093,12,"Algorithms for exploring and searching graphs: breadth-first and depth-first search, Dijkstra, Bellman-Ford, A* and Floyd-Warshall, with bidirectional search, iterative deepening, uniform-cost and greedy best-first search, topological sorting and Johnson's all-pairs algorithm." 2804,greedy-algorithms,Greedy Algorithms,Algorithms that make locally optimal choices at each step.,"algorithms,greedy,optimization",45,1793403093,11,"Greedy algorithms and the problems they solve: activity selection, Huffman coding, Dijkstra, Kruskal, fractional knapsack and job sequencing, extended with Prim's and Boruvka's spanning-tree algorithms, canonical coin change, optimal merge patterns and greedy set-cover approximation." 2887,search-algorithms,Search Algorithms,Reference comparison of fundamental search algorithms.,"algorithms,search,complexity,big-o",46,1793403093,9,"Searching algorithms with best, average and worst time, space and a description: linear, binary, jump, interpolation, exponential and ternary search, plus Fibonacci search, hash-based lookup and binary-search-tree lookup." 2898,sorting-algorithms,Sorting Algorithms,Comparison of fundamental sorting algorithms with time and space complexity.,"algorithms,sorting,complexity,big-o",34,1793403093,12,"Sorting algorithms with best, average and worst time, space, stability and notes: bubble, selection, insertion, merge, quick, heap, counting and radix sort, extended with Timsort, introsort, bucket sort and shell sort."