由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一个open question的讨论
相关主题
那个 google hint words 的老题请问系统设计里的stateless和sticky session有冲突吗?
两道很有意思的面试题目,大家议一议贴道题目
有没有experienced QA 同学对Apple感兴趣可以hash到disk上一个file里的某个位置吗?
Staff Machine Learning/Forecasting Scientist / EngineerCS algorithm question
一道看似不难但难的题an interview algorithm question about finding even occuring freq
征解几道large scale的数字题string matching 需要看KMP 还有其他需要看的吗?
问个问题 (large-scale question)Interview Question- Algorithm
[Job Opening] Senior Game Network Programmerepi 还是 The Algorithm Design Manual
相关话题的讨论汇总
话题: block话题: unique话题: blockid话题: each话题: size
进入JobHunting版参与讨论
1 (共1页)
b*********n
发帖数: 1258
1
Design an algorithm to give unique id for each request, the id should be a
64 bit number. The algorithm should be scalable.
How to make each id unique?
我感觉应该用hash.
If the total memory can not hold all the numbers, we have to save it to Disk
, to get better performance, we don't save it each time an ID is created,but
saved as a block. How to make the id unique even if the machine crash some
ids doesn't write to the memory.
特别是这个问题,没有太好的思路.
还有就是网上看见相似的题目.
Given constant incoming requests, each ass
a*****e
发帖数: 51
2
(1) Why use hashing? Just using a global count, say id. When id is almost
overflow, reset it to 0. Something like id=id%0xFFFFFFFFFFFFFFFE.
(2) Use two global count, say blockID and tempID. id=blockID*BLOCK_SIZE+
tempID. When crash happens, retrieved the last blockID that is saved in disk
, id=(blockID+2)*BLOCK_SIZE+tempID.
(3) Estimate the time for one block (or several block, in order to improve
accuracy), #of unique requests=k*BLOCK_SIZE*T/t, where k is the number of
block in the first estima

【在 b*********n 的大作中提到】
: Design an algorithm to give unique id for each request, the id should be a
: 64 bit number. The algorithm should be scalable.
: How to make each id unique?
: 我感觉应该用hash.
: If the total memory can not hold all the numbers, we have to save it to Disk
: , to get better performance, we don't save it each time an ID is created,but
: saved as a block. How to make the id unique even if the machine crash some
: ids doesn't write to the memory.
: 特别是这个问题,没有太好的思路.
: 还有就是网上看见相似的题目.

1 (共1页)
进入JobHunting版参与讨论
相关主题
epi 还是 The Algorithm Design Manual一道看似不难但难的题
Algorithm in C++大家怎么准备?征解几道large scale的数字题
Algorithms的书问个问题 (large-scale question)
面试的时候可以用STL吗[Job Opening] Senior Game Network Programmer
那个 google hint words 的老题请问系统设计里的stateless和sticky session有冲突吗?
两道很有意思的面试题目,大家议一议贴道题目
有没有experienced QA 同学对Apple感兴趣可以hash到disk上一个file里的某个位置吗?
Staff Machine Learning/Forecasting Scientist / EngineerCS algorithm question
相关话题的讨论汇总
话题: block话题: unique话题: blockid话题: each话题: size