lzhenf

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年3月21日

摘要: 用bitmap方法,内存只需要 512M左右#include <stdio.h>#include <memory.h>#define BYTESIZE 8long long bufferlen =500000000;char *pBuffer = new char[bufferlen]; void setbit(char * p , int posi){ for ( int i = 0 ; i < posi / BYTESIZE ; i++) { p++; } *p = *p | (0x01 << (posi % BYTESIZE)) ;}int ma 阅读全文
posted @ 2012-03-21 23:54 lzhenf 阅读(611) 评论(0) 推荐(1) 编辑

摘要: 某天有1千万条查询,大部分为重复的,可能只有300万条查询,每条查询的长度为1-255字节,请设计算法查找出最热门的10条查询哈希 + 最小堆 时间复杂度为O(nlgk) n为数据量 , k为查询长度,这里为10;#include <stdio.h>#include <cstring>#include <algorithm>using namespace std;#define HASHLEN 2807303#define CHARLEN 30typedef struct node_no_space* ptr_no_space;typedef struct 阅读全文
posted @ 2012-03-21 21:09 lzhenf 阅读(2016) 评论(0) 推荐(0) 编辑