当前位置:网站首页>Bucket sorting in C language
Bucket sorting in C language
2022-07-03 14:36:00 【roseisbule】
When we're dealing with it c When de duplication of super large data in language , The running efficiency of the program will be very low , The running memory will be very large .
Such as this topic , The background gives a huge amount of data , If we write ordinary counting and sorting functions, we will not be able to process these data , So we need to find a stronger idea .
Our normal method is , Create an array , Store every element , But this will cause the array to be very large . So we changed our mind , Use subscripts to store data , Let the element content store the number of occurrences of this small mark , It's easy to solve . The code is as follows .
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define NUM 500000
int main()
{
int arr[NUM] = { 0 };
int num = 0;
int tmp = 0;
scanf("%d", &num);
for (; num >0; num--)
{
tmp = 0;
scanf("%d", &tmp);
arr[tmp]++;
}
for (num = 0; num < NUM; num++)
{
if (arr[num] != 0)
printf("%d ", num);
}
return 0;
}
边栏推荐
- 洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解
- Sword finger offer 28 Symmetric binary tree
- Why is this error reported when modifying records in the database
- Use of constraintlayout
- Pyqt interface production (login + jump page)
- Recent learning summary
- String substitution
- Thread. Sleep and timeunit SECONDS. The difference between sleep
- Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
- Doris学习笔记之数据表的创建
猜你喜欢
使用并行可微模拟加速策略学习
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Protobuf and grpc
Use of constraintlayout
Dllexport and dllimport
Creation of data table of Doris' learning notes
tonybot 人形機器人 紅外遙控玩法 0630
NPM install is stuck with various strange errors of node NPY
提高效率 Or 增加成本,开发人员应如何理解结对编程?
随机推荐
Puzzle (016.3) is inextricably linked
String reverse order
How to query the baby category of tmall on Taobao
SSH access control, blocking the IP when logging in repeatedly to prevent brute force cracking
Find the sum of the elements of each row of the matrix
基因家族特征分析 - 染色体定位分析
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
dllexport和dllimport
556. 下一个更大元素 III : 简单构造模拟题
洛谷P5194 [USACO05DEC]Scales S 题解
论文分享:Generating Playful Palettes from Images
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
How Facebook moves instagram from AWS to its own server
retrofit
添加Zabbix计算类型项目Calculated items
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution
【7.3】146. LRU缓存机制
分布式事务(Seata) 四大模式详解
Preliminary summary of structure