当前位置:网站首页>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;
}
边栏推荐
- Stop asking yourself if you are suitable for software testing
- Thread.sleep和TimeUnit.SECONDS.sleep的区别
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
- 7-6 mixed type data format input
- 7-15 calculation of PI
- tonybot 人形机器人 首次开机 0630
- Accelerating strategy learning using parallel differentiable simulation
- Four data flows and cases of grpc
- 7-28 monkeys choose King (Joseph problem)
猜你喜欢
随机推荐
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
剑指 Offer 28. 对称的二叉树
Tonybot humanoid robot infrared remote control play 0630
Dllexport et dllimport
Find the sum of the elements of each row of the matrix
Creation of data table of Doris' learning notes
使用并行可微模拟加速策略学习
NPM install is stuck with various strange errors of node NPY
7-3 rental (20 points)
1017 a divided by B (20 points)
Luogu p5536 [xr-3] core city solution
Four data flows and cases of grpc
Dllexport and dllimport
Find specified characters
Luogu p3065 [usaco12dec]first! G problem solution
7-19 check denomination (solve binary linear equation)
7-1 positive integer a+b (15 points)
tonybot 人形机器人 首次开机 0630
分布式事务(Seata) 四大模式详解
全文检索引擎Solr系列—–全文检索基本原理