Topics (384k) Articles (398k) Users (410) Discussions (242) Comments (383) Files (13k) New article
An algorithm that maintains information about a contiguous part of a sequence while moving its endpoints. Updating a fixed-length window sum needs subtraction of the outgoing term and addition of the incoming term. A window product can be updated by division only when the outgoing factor is nonzero; zero counts or zero-free segments handle that exception.
Build a candidate incrementally, abandoning a partial candidate as soon as no valid completion is possible. A depth-first search explores one choice, restores the previous state, and tries the next. Constraint propagation and bounds can greatly reduce the visited state space, although the worst-case time complexity may remain exponential.
A search algorithm looks for an object satisfying a specified condition within a collection or state space. Linear search inspects entries directly; binary search exploits sorted order; breadth-first search explores graph states by distance from a start. The specification should say whether to return one witness, every witness or proof of absence. A procedure that eventually finds every reachable witness may still fail to terminate when none exists in an infinite space. Representation and available structure determine which candidates can safely be ruled out without inspection.
Given a finite sequence of real numbers, find a nonempty contiguous block with maximum sum. Its restriction to contiguous blocks distinguishes it from choosing an arbitrary subset. The problem admits a linear-time solution using Kadane's algorithm.
A family of algorithms that exploit monotonically changing geometric directions while traversing sorted points or the boundary of a convex polygon. For example, after sorting rays by polar angle around a point, a second index can advance monotonically to identify all rays lying in each open half-plane. Collinear rays require consistent boundary handling.
For a deterministic iteration on a finite set, move one pointer by one step and another by two steps. They eventually meet inside the repeated cycle. Restarting one pointer at the initial state and advancing both by one step locates the cycle entrance; a further traversal measures its length. The method uses constant extra space complexity and time proportional to the preperiod plus cycle length.
Redelmeier's algorithm enumerates fixed polyominoes, identifying translations while retaining different orientations. Put the leftmost cell of the bottom row at the origin. Allowed cells lie above the horizontal axis, or on it at nonnegative horizontal coordinates.
Maintain the occupied set of cells, an untried frontier of adjacent cells, and exclusions inherited from earlier branches. Remove a frontier cell , occupy it, and add neighbours newly exposed by . Recurse with a copy of the updated frontier. On returning, undo those new neighbours and remove from the occupied set, but keep excluded from later sibling branches.
The exclusion prevents a later branch from reconstructing a polyomino already assigned to the branch containing . Requiring new cells to touch the occupied set preserves connectivity; every canonical polyomino has a branch determined by its first available frontier choice. Thus each fixed polyomino is visited once.
At size two there are two fixed polyominoes, horizontal and vertical, but one free polyomino after identifying rotations. Counting free polyominoes needs an additional treatment of symmetry.[ref]
A string-searching algorithm locates occurrences of a pattern in a text, typically requiring a contiguous substring match. For text
ababa and pattern aba, zero-based matches start at zero and two; overlaps count unless excluded by the specification. The direct algorithm compares the pattern at each start and can require character comparisons. The Knuth-Morris-Pratt algorithm reuses prefix information for linear total scanning work. State the alphabet, case handling and empty-pattern convention: matching bytes, Unicode code points and user-perceived characters can describe different tasks.The Tonelli-Shanks algorithm finds a square root of a quadratic residue modulo an odd prime number . Handle separately and use the Legendre symbol to reject a quadratic nonresidue. Write with odd, choose a quadratic nonresidue , and initializemodulo . Maintain , with of multiplicative order and of multiplicative order dividing .
If , find the least with . Set and updateThe multiplicative order of decreases because its last nontrivial power and that of are both minus one. Thus strictly decreases. At , the invariant gives .
The Aho-Corasick algorithm reports occurrences of a finite collection of nonempty pattern strings in one string. It builds an Aho-Corasick automaton from their trie. Each scanned character extends the current state; when no edge matches, failure links find a shorter matching suffix. Report the current terminal pattern string and the terminal ancestors reached through output links.[ref]
Efficient String Matching: An Aid to Bibliographic Search by Alfred V. Aho and Margaret J. Corasick. abstract, keyword-matching machine and single-pass search
The state represents the longest suffix of the scanned text that is a prefix of some pattern string. This invariant explains correctness: a match ending now is exactly a terminal suffix represented by that state or a failure link ancestor. It also reports overlaps. With pattern strings
ab, bab, bc, scanning babc reports ab and bab at position three, then bc at position four.For a fixed-size alphabet, completed transitions and output links give total time, where is total pattern string length, text length and the number of reported occurrences. The term is unavoidable when listing every match. Store terminal output links instead of copying every inherited match list: copied suffix lists can greatly enlarge preprocessing.
The two-pointer technique maintains two indices whose monotone movement avoids revisiting candidate pairs. To find two values summing to in an increasing array, start at its ends. If their sum is too small, move the left index right: every pair using the old left value is too small. If too large, move the right index left by the symmetric argument. Each step eliminates one index, so after sorting the scan takes time. The correctness depends on sorted order; blindly applying the rule to unsorted inputs can discard a valid pair.
Exponential search locates a target's possible range in a sorted sequence by probing indices until the target is bounded above or the sequence ends, then uses binary search inside the final bracket. If the target lies near index , this takes probes under random-access and constant-comparison assumptions. For an unbounded monotone predicate, the same method brackets the first true index. It is useful when the relevant prefix is much shorter than the whole sequence or its length is not initially known. Finite sequences still require bounds checks at each probe.
A bitwise operation applies a Boolean operation separately to corresponding positions of binary representations. For four-bit values
1010 and 1100, AND gives 1000, OR gives 1110, and exclusive or gives 0110. Bit shifts move positions, while bitwise complement reverses each bit. The representation width and signedness matter: fixed-width machine arithmetic and unbounded integers need not interpret leading bits alike. These operations are useful for compact sets, flags and bit parallelism. They differ from logical operations that test the truth of entire operands.[ref]https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types. Python language documentation, Bitwise Operations on Integer Types
The Bostan-Mori algorithm computes without expanding all preceding coefficients. Work over a commutative ring with a unit; then the quotient defines a formal power series.
Set and . The polynomial contains only even powers. DefineBecause the denominator is even, selecting the numerator parity matching provesIterate until , then return . With bounded numerator/denominator polynomial degrees , the arithmetic complexity is , where is the cost of multiplying degree- polynomials.
For , the denominator update is . An odd index also multiplies the numerator by , recovering the familiar binary-powering pattern.[ref]
Unification finds a substitution making given first-order terms syntactically identical. In first-order unification, a substitution replaces variables by first-order terms while leaving function symbols fixed. A most general unifier captures the necessary identifications: every other unifier follows by a further substitution.[ref]
For example, and have most general unifier . The variable remains free; assigning it a particular first-order term gives a more specific unifier. Requiring forces both and , so distinct constant symbols make it impossible.
Syntactic identity is essential. With addition treated as a binary function symbol, the first-order terms and are different even though their values agree under ordinary arithmetic. Equational unification incorporates specified identities and is a different problem. For finite first-order terms, the occurs check rejects : a finite first-order term cannot equal one of its proper subterms. Unification makes resolution possible by aligning atomic formulas before inference.
Rearranging a finite sequence according to a specified order while preserving its entries and their multiplicities. A sorting algorithm performs this operation; lexicographic order supplies a common order for tuples or strings.
Pinned article: Introduction to the OurBigBook Project
Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
Intro to OurBigBook
. Source. We have two killer features:
- topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculusArticles of different users are sorted by upvote within each article page. This feature is a bit like:
- a Wikipedia where each user can have their own version of each article
- a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.Figure 1. Screenshot of the "Derivative" topic page. View it live at: ourbigbook.com/go/topic/derivativeVideo 2. OurBigBook Web topics demo. Source. - local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
- to OurBigBook.com to get awesome multi-user features like topics and likes
- as HTML files to a static website, which you can host yourself for free on many external providers like GitHub Pages, and remain in full control
Figure 2. You can publish local OurBigBook lightweight markup files to either OurBigBook.com or as a static website.Figure 3. Visual Studio Code extension installation.Figure 5. . You can also edit articles on the Web editor without installing anything locally. Video 3. Edit locally and publish demo. Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension. - Infinitely deep tables of contents:
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact





