Linear structures consist of a finite sequence of elements with identical properties. Common linear data structures include arrays, linked lists, stacks, queues, and strings. While linear structures follow a continuous logical arrangement, their physical storage may be either contiguous or non-conti...
Array-Based Linear List Manipulations The following implementation uses a fixed-size array to simulate a dynamic linear list. All mutations reflect directly on a global counter size. Core Operation Implementations #include <iostream> const int CAPACITY = 10000; int buffer[CAPACITY]; int size =...
Working with singly linked lists requires a firm grasp of pointer manipulation and edge-case handling. The following sections break down three classic problems: removing nodes by value, building a custom linked list with index-based operations, and reversing a list in-place. Eliminating Nodes with a...
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...
A heap is a complete binary tree structure typically implemented using a dynamic array. This implementation focuses on a min-heap, where the root node holds the smallest value and each parent node is less than or equal to its children. Data Structure and Function Prototypes #ifndef HEAP_H #define HE...
Problem Overview Consider an n×m grid where each cell contains its position number: the cell at row i, column j holds value (i-1)×m + j. We process q queries, each specifying a position (x, y). The queried element is removed and appended to the end of its row, while the element displaced from the ro...
Contest OverviewMisreading the first problem caused a 20-minute delay. The second problem presented a psychological barrier despite being solvable for partial points. Skipping the third problem's statement cost easy points, while the fourth problem failed due to inefficient modular inverse preproces...
Search algorithms are fundamental techniques for locating specific elements within data collections. These collections may be stored as arrays, linked lists, or hash tables. Choosing the right search strategy significantly impacts application performance. Search Algorithm Categories Sequential Searc...
Core Concepts and Prerequisites To effectively implement merging operations on range-based data structures, understanding dynamic node allocation and order statistic trees is essential. Standard segment trees often consume excessive memory when built fully; dynamic initialization allowss resources t...
LinkedList Header Definition The underlying data structure is a singly linked list. We define the node structure to hold generic data, which will be specialized for the contact information later. #ifndef LINKED_LIST_H #define LINKED_LIST_H #include <stdlib.h> #include <assert.h> #include...