Skip to main content

4 posts tagged with "Algorithm"

View All Tags

二分查找

· 9 min read
therainisme
快乐!

预习一下 lower_bound 的用法与写法

lower_bound 功能:在连续递增的数组中返回一个下标 i,其对应的数为 x。给定目标值 tx 是第一个满足 t <= x 的数。

例如,下面的序列中,当 t = 2 时,lower_bound 返回的 i2

1 1 *2* 2 3 4 5 5 6

MapReduce

· 35 min read
therainisme
快乐!

Abstract  MapReduce is a programming model and an associated implementation for processing and generating large data sets. Users specify a map function that processes a key/value pair to generate a set of intermediate key/value pairs, and a reduce function that merges all intermediate values associated with the same intermediate key. Many real world tasks are expressible in this model, as shown in the paper......

MapReduce: Simplified Data Processing on Large Cluster 的部分翻译

字符串哈希

· 4 min read
therainisme
快乐!

简介

该算法通过把字符串变成一个 pp 进制数字(哈希值),实现将不同的字符串映射到不同的数字。计算方法是,对形如 X1X2...XnX_{1}X_{2} ... X_{n} 的字符串,将每一位上的字符 ASCII 码乘上 pp 的不同次方之和来计算哈希值:

(X1×Pn1+X2×Pn2++Xn1×P1+Xn×P0)modQ(X_{1} \times P^{n-1} + X_{2} \times P^{n−2} + ⋯ + X_{n−1} \times P^1 + X_n \times P^0) \mod Q