Redian新闻
>
请教一下,多谢
avatar
请教一下,多谢# Living
f*w
1
Assuming that you are only allowed a constant amount of time for
initialization, design a representation for a table that allows one to
search, insert, and delete values in worst case time O(1), assuming that
each value is in the range 1 to m.
You may assume that no more than n insertions will be done and, that m+n + c
units of
space are available for you to use, where c is a small constant of your
choosing (e.g. 3 or 4).
Note that in this problem m and n are problem inputs, hence they are not
constants, hence initializing the entire space is not allowed, since that
would require time O(m+n).
我开始想的是初始化一个m维数组存个数……但人家说了m不是常数,不能直接这样分配
avatar
N*1
2
做了个小院子的工作,装出了15个黑袋子的土,石头,MULCH,树根。大家一般怎么倒
掉?日常收垃圾的肯定不会受的?
avatar
l*a
3
fast search ==>hashtable
easy to insert/delete ==> linked list
use the two DS together may work for your case

c

【在 f*******w 的大作中提到】
: Assuming that you are only allowed a constant amount of time for
: initialization, design a representation for a table that allows one to
: search, insert, and delete values in worst case time O(1), assuming that
: each value is in the range 1 to m.
: You may assume that no more than n insertions will be done and, that m+n + c
: units of
: space are available for you to use, where c is a small constant of your
: choosing (e.g. 3 or 4).
: Note that in this problem m and n are problem inputs, hence they are not
: constants, hence initializing the entire space is not allowed, since that

avatar
f*w
4

hash table with n entries? each entry is a link list? (insert/delete the
same number?)
sounds good:)

【在 l*****a 的大作中提到】
: fast search ==>hashtable
: easy to insert/delete ==> linked list
: use the two DS together may work for your case
:
: c

avatar
w*x
5

hash table的桶数量也要根据元素个数调整啊, 要么初始化不是O(1), 要么insert的时
候不是O(1), 不知道这题要干什么?

【在 l*****a 的大作中提到】
: fast search ==>hashtable
: easy to insert/delete ==> linked list
: use the two DS together may work for your case
:
: c

avatar
l*e
6
插入A[i]=k B[k]=m ++k
查找 A[i]删除 在就B[A[i]]=-1

c

【在 f*******w 的大作中提到】
: Assuming that you are only allowed a constant amount of time for
: initialization, design a representation for a table that allows one to
: search, insert, and delete values in worst case time O(1), assuming that
: each value is in the range 1 to m.
: You may assume that no more than n insertions will be done and, that m+n + c
: units of
: space are available for you to use, where c is a small constant of your
: choosing (e.g. 3 or 4).
: Note that in this problem m and n are problem inputs, hence they are not
: constants, hence initializing the entire space is not allowed, since that

avatar
a*y
7
LRU like design?
hashtable + linkedlist
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。