计数排序时我们使用一个数组来记录出现的数字的次数,而当数据范围太大时,无法建立一个那么大地数组(而且可能空间利用率很低,太浪费),此时可以改用hash table 、 binary search tree等数据结构作为lookup table

#include<cstdio>
#include<map>
#include <iostream>
using namespace std;
int main(){
map<int,int> b;
map<int,int>::iterator i;
int a[]={
,,,,,,,,,
};
for(int i=;i<;i++){
b[a[i]]++;
}
for(i=b.begin();i!=b.end();i++){
cout<<i->first<<' '<<i->second<<"\n";
}
}

最新文章

  1. php报错 ----&gt; Call to undefined function imagecreatetruecolor()
  2. Python调用服务接口
  3. Tomcat启动服务报错:Unknown version string [3.1]. Default version will be used.
  4. POJ 1106 Transmitters(计算几何)
  5. 安装LNMP之后出现 Access denied.解决方法
  6. (整理)SQLServer_DBA 工具
  7. oracle 中文乱码---查看和修改客户端字符集
  8. Vertica笔记
  9. markdownpad2使用说明
  10. hdu 1288 Hat&#39;s Tea
  11. iOS11和机器学习CoreML库
  12. thinphp原生异步分页
  13. 【并查集】HDU 1325 Is It A Tree?
  14. InnoDB一棵B+树可以存放多少行数据?
  15. Linux mint界面过小无法安装(解决方法)
  16. eBay账号token授权
  17. Linux 文本处理工具记录
  18. java 的基本数据类型及转换
  19. 数据结构图解(递归,二分,AVL,红黑树,伸展树,哈希表,字典树,B树,B+树)
  20. ujquery.fancybox api开发文档中文翻译版

热门文章

  1. Spring的扩展
  2. Redis集群进阶之路
  3. 安装Flutter环境
  4. Codeforces Round #482 (Div. 2) : Kuro and GCD and XOR and SUM (寻找最大异或值)
  5. 22-Consent 确认逻辑实现
  6. BZOJ1222_ 产品加工_KEY
  7. == vs === in Javascript
  8. Ruby基础教程 1-10
  9. 「日常训练」Kefa and Dishes(Codeforces Round #321 Div. 2 D)
  10. Linux命令应用大词典-第32章 性能监控