String Hashing Techniques and Applications
Properties of String Hashing
Different hash values guarantee different strings.
Identical hash values don't guarantee identical strings (though probability is high).
Modulus Selection
Prime moduli are preferable based on number theory. For example, (ax + b) mod p distributes with interval gcd(a, p). The modulus must prevent overflow in 64-bi ...
Posted on Wed, 29 Jul 2026 16:20:42 +0000 by lalabored
Data Structures Implementations: Leaf Counting, Linked List Insertion, and Unique Like Ranking
Counting Leaf Nodes in a Binary Tree
Calculate the number of leaf nodes within a binary tree. A leaf node is defined as a node where both the left and right child pointers are null.
#include <stdio.h>
#include <stdlib.h>
typedef char ElemType;
typedef struct BiTNode {
ElemType data;
struct BiTNode *lchild, *rchild;
} BiTNod ...
Posted on Tue, 28 Jul 2026 16:53:11 +0000 by glence
Computing All Integer Factors in Ascending Order with Rust
A straightforward Rust implementation for finding all factors of a number is shown below. This approach iterates up to the square root of the input value.
fn compute_factors_simple(num: u64) -> Vec<u64> {
let sqrt_val = (num as f64).sqrt().floor() as u64;
let mut factors = Vec::new();
for divisor in 1..=sqrt_val {
i ...
Posted on Tue, 28 Jul 2026 16:25:21 +0000 by pazzy
Solutions for Codeforces Round 855 (Div. 3)
Problem A: Is It a Cat?
Givan a string and its length, output "YES" if the string satisfies the following conditions; otherwise, output "NO":
The string consists of exactly four segments.
Each segment contains only one letter (case-insensitive), in the exact sequence: 'm', 'e', 'o', 'w'.
There are t test cases.
Approach
Th ...
Posted on Mon, 27 Jul 2026 17:02:01 +0000 by mindrage00
Decoding Java's Seeded Random: How 'Hello World' Emerges from Chaos
The Mystery of Deterministic Randomness
Consider this peculiar Java code that outputs "hello world" despite using seemingly random operations:
public class RandomStringGenerator {
public static void main(String[] args) {
System.out.println(createRandomString(-229985452) + " " + createRandomString(-147909649));
}
public st ...
Posted on Mon, 27 Jul 2026 16:54:46 +0000 by unknown
Implementing a Sorted Singly Linked List in C
A singly linked list is built using a structure containing data and a pointer to the next node. This dynamic data strcuture supports efficient insertion, deletion, and traversal operations.
Below is a concise implementation that maintains elements in ascending order during insertion:
#include <stdio.h>
#include <stdlib.h>
typedef s ...
Posted on Sun, 26 Jul 2026 17:18:45 +0000 by dlgilbert
Memory Allocation and String Manipulation in C: Arrays vs Pointers
In C programming, handling strings requires a clear understanding of how memory is allocated. Strings can be managed using either character arrays or character pointers, each behaving differently regarding memory size and data manipulation.
1. String Manipulation Using Character Arrays
When using a character array, memory is statically allocate ...
Posted on Sat, 25 Jul 2026 17:09:06 +0000 by ridckie_rich
Solutions for Codeforces Educational Round 162 Problems A to D
A. Moving Chips
A greedy approach is applicable. Chips can only move left to the nearest empty cell. Therefore, only the longest contiguous segment of 1s matters (denoted as s). The chips within this segment need to be consolidated. The minimal number of moves equals the number of 0s inside this segment.
#include <iostream>
#include <v ...
Posted on Fri, 24 Jul 2026 17:04:43 +0000 by jreed2132
C Programming: Linked List Operations for Data Structure Management
Linked List Overview
A linked list represents a linear data structure where elements are stored in non-contiguous memory locations. Each element maintains a reference to the next element, creating a sequence through pointer connections rather than physical adjacency. Each node consists of two components: a data field storing the actual value an ...
Posted on Fri, 24 Jul 2026 16:58:57 +0000 by darkknightgaury
Implementing Stack Data Structures in Java
A stack is a linear data structure that restricts insertion and deletion operations to one end—commonly referred to as the top. This constraint enforces a Last-In-First-Out (LIFO) behavior: the most recently added element is the first to be removed.
Core Terminology
Top: The active end where all push and pop operations occur.
Bottom: The fixed ...
Posted on Fri, 24 Jul 2026 16:29:29 +0000 by elhelaly1999