avatar
paper help (转载)# Biology - 生物学
g*y
1
这些东西我很都不熟悉。希望有高手指点指点,呵呵
1. Mempool design with 30k limit.
mempool是应该在一开始就allocate 30k 连续的内存,然后分配和管理?
或者是每次call allocate(n)的时候再通过operator new[]来分配内存,update size
member?如果是的话,free(ptr, n)怎么写呢?貌似operator delete[]不能带size参
数啊?
总之我就是对memory design这块很不熟悉。。。
2. Implement put/get methods of a fixed size cache with LRU replacement
algorithm.
这个是不是用fixed size的max heap来实现?每个元素定义一个key,表示距离上次使
用的时间,每使用一个元素,就相当于是把它的key更新为比当前最小值更小的数,然
后做heapify()操作?
每put一个元素,就assign新元素一个最小的key,然后用新元素替换掉堆顶点,然后做
heapify?
3. Write
avatar
m*f
3
请问你这是什么职位的面试问题啊
avatar
g*y
5
就是一般的SDE的职位的面试题吧
都是些精华区等地方看过来的题

【在 m*****f 的大作中提到】
: 请问你这是什么职位的面试问题啊
avatar
k*k
7
2. Implement put/get methods of a fixed size cache with LRU replacement
algorithm.
refer to java LinkedHashMap
basic idea is following:
store elements using hash map/table, use an additional double link list to link up each elements
1) the list keeps a head/tail pointer
2) when an element is inserted/cached, add to head
3) when an element is removed
3.a remove from the hashmap
3.b remove from list, relink the linked list
3.c if that element is head or tail, update list accordingly
4) when an ele
avatar
g*y
9
嗯,对,thx~ 可惜我貌似记得有人说是用heap,就往heap那里想了。。。
any more answer to other questions?

up

【在 k*k 的大作中提到】
: 2. Implement put/get methods of a fixed size cache with LRU replacement
: algorithm.
: refer to java LinkedHashMap
: basic idea is following:
: store elements using hash map/table, use an additional double link list to link up each elements
: 1) the list keeps a head/tail pointer
: 2) when an element is inserted/cached, add to head
: 3) when an element is removed
: 3.a remove from the hashmap
: 3.b remove from list, relink the linked list

avatar
L*O
10
我看到楼主的名字进来了。。
avatar
b*n
11
对于第2条,插入一个element的时候,应该放到head,不是tail吧
其次,应该是一个doubly link list,对吧.

up

【在 k*k 的大作中提到】
: 2. Implement put/get methods of a fixed size cache with LRU replacement
: algorithm.
: refer to java LinkedHashMap
: basic idea is following:
: store elements using hash map/table, use an additional double link list to link up each elements
: 1) the list keeps a head/tail pointer
: 2) when an element is inserted/cached, add to head
: 3) when an element is removed
: 3.a remove from the hashmap
: 3.b remove from list, relink the linked list

avatar
l*3
12
?????

【在 L**********O 的大作中提到】
: 我看到楼主的名字进来了。。
avatar
k*k
13
Yes. should be added to the head.
thx.
and it is double linked list. you can access the tail.prev (the 2nd least
recent) from tail (the least recent) when perform removing.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。