- algorithms
- rust
- data-structures
- notes
•
•
•
-
Range Minimum Queries
On a static array, a range minimum query can be answered in constant time with linear space. In these notes we get there in four steps, from the table of all the answers to the sparse table, blocks and Cartesian trees, and then we use constant-time RMQ to list the distinct colors in a range in optimal time. Finally, we use the Cartesian tree as a way to look at an array, on a problem of jumps between inversions. With a Rust implementation.
-
Segment Tree
The Segment Tree is the Swiss army knife of range queries. It answers range sums, range minimums and many other range queries on a dynamic array in logarithmic time. In these notes we build it on a running example, analyze it, and extend it with lazy propagation and persistence, with a Rust implementation.
-
Tiny but Mighty: Super-Short, Super-Clever Algorithms
Six small problems with surprising solutions. The riddle of the 100 prisoners, a duplicate found in constant space, Floyd's cycle finding, the majority element, the Misra-Gries heavy hitters, and dominoes on a chessboard. Each one is followed on a running example, with proofs, complexities and Rust code.
-
Mo's Algorithm
The Mo's Algorithm is a powerful and efficient technique for solving a wide variety of range query problems. It becomes particularly useful for kinds of queries where the use of a Segment Tree or similar data structures is not feasible.
-
Dynamic Prefix Sums with Fenwick Tree
The Fenwick Tree, also known as the Binary Indexed Tree (BIT), efficiently manages the prefix sum of an array, even as it undergoes updates. In these notes, we introduce this elegant data structure and describe a basic Rust implementation.
-
The Power of Prefix Sums
Prefix sums offer an elegant and efficient solution to a variety of problems. In these notes, we showcase several such problems and provide their solutions with Rust implementations.
-
Sweep Line Algorithm
The Sweep Line Algorithm is a powerful paradigm for solving a variety of problems in computational geometry. In these notes, we employ it to address problems both on a line and in a plane, providing Rust implementations for their solutions.
-
Applications of Binary Search
Binary search is undeniably one of the most renowned and fundamental algorithms in computer science. In these notes, we delve into problems that can be solved using the idea of 'Binary Searching for the Answer'.
-
Sliding Window Maximum
The Sliding Window Maximum problem is a classic algorithmic challenge that involves processing an array in a sliding window fashion. The goal is to find the maximum element within a fixed-size window as it moves through the array. In these notes, we describe several possible solutions to this problem and their implementations in Rust.
-
HandsOn 3
Third hands-on for the course Competitive Programming and Contests at University of Pisa
-
HandsOn 2
Second hands-on for the course Competitive Programming and Contests at University of Pisa
-
HandsOn 1
First hands-on for the course Competitive Programming and Contests at University of Pisa