由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - [板上牛人多]问个算法题
相关主题
问个概率题问个debug和release mode的问题
两个programming pearls的习题请教有面过knight的吗
几个多次被问到的c++问题请教问个opt身份问题
C++定义数组长度可以写成int a[n]吗?C++ Q68: initialization (skillport)
搞不清C++里的constant expression问一个c++问题关于reference vs. pointer
static initialization dependency c++ (转载)面试就是面试问题,跟实际问题差太远
新鲜 interveiw questionssingleton pattern problem
大家谈谈看???问个static STL container的问题
相关话题的讨论汇总
话题: assuming话题: hence话题: constant话题: time话题: insert
进入JobHunting版参与讨论
1 (共1页)
f*******w
发帖数: 1243
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不是常数,不能直接这样分配
l*****a
发帖数: 14598
2
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

f*******w
发帖数: 1243
3

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

w****x
发帖数: 2483
4

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

l***e
发帖数: 6
5
插入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

a*******y
发帖数: 1040
6
LRU like design?
hashtable + linkedlist
1 (共1页)
进入JobHunting版参与讨论
相关主题
问个static STL container的问题搞不清C++里的constant expression
问个算法题2static initialization dependency c++ (转载)
问个h1b的事情新鲜 interveiw questions
也问个opt的问题大家谈谈看???
问个概率题问个debug和release mode的问题
两个programming pearls的习题请教有面过knight的吗
几个多次被问到的c++问题请教问个opt身份问题
C++定义数组长度可以写成int a[n]吗?C++ Q68: initialization (skillport)
相关话题的讨论汇总
话题: assuming话题: hence话题: constant话题: time话题: insert