摘要: 使用map统计次数。#include #include #include #include #include using namespace std;void main(){ typedef map::iterator mit; map ma; mit it; ifstream in("in.txt"); int c=0; string str; string st; while( getline(in,str) ) { istringstream ist(str); while( ist>>st ) { it=ma.find(st); if( it!=ma.e 阅读全文
posted @ 2013-08-24 13:57 l851654152 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 一.hash海量数据处理问题:1.最多问题2.topK问题3.相同问题主要是分为三步1.分而治之,这一步是当内存不足时存在如果内存充足可以不需要此步。2.使用字典树trie(针对单词)或者hash_map统计次数(topK问题,最多问题),使用hash_set判断是否有重复。时间复杂度O(N)3.使用堆排序找出最大K个元素。时间复杂度O(N'*logK)http://www.cnblogs.com/sooner/p/3266545.html二.bitmap解决是否存在重复的数,是否存在某个数。是否存在某个数,编程珠玑第一章有具体的例子2.5亿个整数中找出不重复的整数的个数,内存空间不足 阅读全文
posted @ 2013-08-24 13:22 l851654152 阅读(179) 评论(0) 推荐(0) 编辑