Fading Coder

One Final Commit for the Last Sprint

Using Union-Find with Path Compression and Dynamic Programming for Truth-Teller Identification

Problem Context An island has two types of inhabitants: truth-tellers, who always tell the truth, and liars, who always lie. Each inhabitent has a unique integer identifier. You are allowed n questions. Each question must be direcetd to one inhabitant, asking whether another inhabitant is a truth-te...

2023.10.19 Full Simulation Exam Summary

2023.10.19 Full Simulation Exam Summary Overview Schedule Exam Results Exam Reflection Problems T1 T2 T3 T4 Overview Schedule 8 : 00 ∼ 8 : 20 \qquad 8:00\sim 8:20 8:00∼8:20 Read through the problem statements, and got a general idea of each question in my mind, thinking briefly. The exam felt very f...

Implementing Binary Trees, Tries, and Union-Find in Rust

Binary Tree Implemented with Option<Box<T>>. Box is a smart pointer that allocates on the heap, ideal for recursive types that would ohterwise have unbounded size. LeetCode often uses Option<Rc<RefCell<T>>>, which is quite bloated. #[derive(PartialEq)] enum ChildSide {...

Union-Find Data Structure Implementation and Variations

Understanding Union-Find Union-Find is a data structure designed to manage relationships between sets, enabling operasions like determining set membership and merging distinct sets. Consider a practical scenario: Initially, Xiao Ming belongs to one family set and Xiao Hong to another. When they marr...

Union-Find Data Structure Implementation for Graph Connectivity

Graph Connectivity Using Union-Find The problem involves determining whether a path exists between two nodes in an undirected graph represented by edge pairs. While traditional graph search algorithms like BFS or DFS could solve this, the Union-Find data structure provides a more efficient approach...

Island Grouping and Treasure Counting via Union-Find on Flattened Grids

Coordinate Linearization for Grid Structures To efficiently apply disjoint set operations on a two-dimensional matrix of dimensions $H \times W$, encode each cell position $(r, c)$ into a scalar identifier using the formula $id = r \times W + c$. This mapping establishes a bijection between matrix c...

Subgroup Order and Inversion Count in Permutation Groups

Two notable problems involving permutation group subgroups are determining the subgroup order (e.g., LOJ177) and counting inversions (e.g., Grupa Permutacji). Surprisingly, both admit polynomial-time solutions, leveraging a key property of "uniformity" in the generated subgroup. Uniformity...

Union-Find Data Structure and Island Counting Problem

Union-Find is a tree-based data structure designed to handle disjoint sets, supporting operations like merging two sets and querying connectivity. It efficiently addresses problems involving connectivity and merging of non-overlapping collections. In Union-Find, each set is represented as a tree whe...

Understanding and Implementing Union-Find Data Structures for Connectivity Problems

Union-Find, also known as Disjoint Set Union (DSU), is a data structure designed to efficiently handle connectivity queries and union operations betwean elements. Its primary use is to determine if two elements belong to the same connected component or set. Core Operations Union (Join): Merges the s...