由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - an interview problem
相关主题
弱问:C#定义的class里面直接new出来的成员存在了哪里?a C question
a template counting - anybody understand this?static variable存在heap还是stack?
求教一个perl问题a simple question
cgi GET method: display results for the 1st time请问heap sort 数组时数组用preorder顺序存储怎么实现?
pdfjs displaying pdf issue来几个C++测试题
何谓 heap array?stack/heap corruption
C语言的变量都一定要放在stack上吗?不理解memory leak
how much slower: heap vs stack memory allocation?linux 下从c++动态内存操作问题,heap size不够还是别的?
相关话题的讨论汇总
话题: problem话题: heap话题: store话题: interview话题: frequnecy
进入Programming版参与讨论
1 (共1页)
m***t
发帖数: 254
1
write the program for displaying the ten most frequent words in a file such
that your program should be efficient in all complexity measures.
I think hash table with counting will be a natual solution, but not sure if
it is a best fit for this problem.
m******k
发帖数: 43
2
hashtable or b+ tree/trie like dictinonary data structure etc only provide
fast search/index, so still need additional data structure on the frequnecy
order statistics. A min-heap is ok. or you can use another b+ tree to store
the frequency as key

such
if

【在 m***t 的大作中提到】
: write the program for displaying the ten most frequent words in a file such
: that your program should be efficient in all complexity measures.
: I think hash table with counting will be a natual solution, but not sure if
: it is a best fit for this problem.

m***t
发帖数: 254
3
I guess u mean max heap to store frequency, right?

frequnecy
store

【在 m******k 的大作中提到】
: hashtable or b+ tree/trie like dictinonary data structure etc only provide
: fast search/index, so still need additional data structure on the frequnecy
: order statistics. A min-heap is ok. or you can use another b+ tree to store
: the frequency as key
:
: such
: if

m******k
发帖数: 43
4
I mean a min-heap of size 10 store top 10 most frequence words on the fly.
because we need to compare other candidates with the least frequent one of
the top 10 to determine whether do a replcaement. Other operation on the min
-heap includes increase_key if anyone of the current top 10 get hit again.
of course, a max-heap also works, but it seems you need to store the entire
N elements to determine the top 10.

I guess u mean max heap to store frequency, right?
frequnecy
store

【在 m***t 的大作中提到】
: I guess u mean max heap to store frequency, right?
:
: frequnecy
: store

m***t
发帖数: 254
5
//blush. That is absolutely right.

min
entire

【在 m******k 的大作中提到】
: I mean a min-heap of size 10 store top 10 most frequence words on the fly.
: because we need to compare other candidates with the least frequent one of
: the top 10 to determine whether do a replcaement. Other operation on the min
: -heap includes increase_key if anyone of the current top 10 get hit again.
: of course, a max-heap also works, but it seems you need to store the entire
: N elements to determine the top 10.
:
: I guess u mean max heap to store frequency, right?
: frequnecy
: store

1 (共1页)
进入Programming版参与讨论
相关主题
linux 下从c++动态内存操作问题,heap size不够还是别的?pdfjs displaying pdf issue
wierd problem何谓 heap array?
问个INTERVIEW QUESTIONC语言的变量都一定要放在stack上吗?
如何将若干已升序排序好的数组合并在一起,并仍然是升序?how much slower: heap vs stack memory allocation?
弱问:C#定义的class里面直接new出来的成员存在了哪里?a C question
a template counting - anybody understand this?static variable存在heap还是stack?
求教一个perl问题a simple question
cgi GET method: display results for the 1st time请问heap sort 数组时数组用preorder顺序存储怎么实现?
相关话题的讨论汇总
话题: problem话题: heap话题: store话题: interview话题: frequnecy