当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
retrofit
Detailed explanation of four modes of distributed transaction (Seata)
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
Programming language: the essence of type system
Showmebug entered Tencent conference, opening the era of professional technical interview
修改数据库中的记录为什么报这个错
MySQL multi table query subquery
论文分享:Generating Playful Palettes from Images
X86 assembly language - Notes from real mode to protected mode
Accelerating strategy learning using parallel differentiable simulation
随机推荐
tonybot 人形机器人 查看端口并对应端口 0701
论文分享:Generating Playful Palettes from Images
7-1 positive integer a+b (15 points)
Output student grades
NPM install is stuck with various strange errors of node NPY
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
retrofit
FPGA blocking assignment and non blocking assignment
Luogu p3065 [usaco12dec]first! G problem solution
Why is this error reported when modifying records in the database
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
npm install卡住与node-npy的各种奇怪报错
Showmebug entered Tencent conference, opening the era of professional technical interview
556. 下一个更大元素 III : 简单构造模拟题
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution
Zzuli:1047 logarithmic table
提高效率 Or 增加成本,开发人员应如何理解结对编程?
7-22 tortoise and rabbit race (result oriented)
7-3 count the number of words in a line of text
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)