当前位置:网站首页>Bit group sort
Bit group sort
2022-06-22 08:25:00 【ambition_ forever】
1、 The premise of using digit group sorting is that the elements in the array cannot have duplicate numbers , And the array can be unordered , However, there is a maximum range limit for the occurrence of elements in an array .
2、 Epoch array , Store the elements of the original array in the specified bit of the pre created bit group .
3、 Re traverse each bit in the bit array if it is true Transformation of , Is attached to the final result .
// Use BitSet Sort
private static String sortNums(Integer[] integers) {
long start = System.currentTimeMillis();
System.out.println(" Start sorting - Use BitSet Sort ");
int len = integers.length;
StringBuilder sb = new StringBuilder();
BitSet bitSet = new BitSet(len);
bitSet.set(0, len, false);
for (Integer integer : integers) {
bitSet.set(integer, true);
}
sb.append("[");
for (int i = 0; i <= len; i++) {
if (bitSet.get(i)) {
sb.append(i);
}
if (bitSet.get(i + 1)) {
sb.append(", ");
}
}
sb.append("]");
System.out.println(" Sort complete , Time consuming :" + (System.currentTimeMillis() - start) + " millisecond ");
return sb.toString();
}
public static void main(String[] args) {
Integer[] integers = {3, 2, 1, 4, 6, 5, 0};
System.out.println(Arrays.toString(integers));
String sortNums = sortNums(integers);
System.out.println(sortNums);
}
边栏推荐
- 邮件巨头曝严重漏洞,用户数据被窃取
- 读取jar包里面文件夹下的所有文件
- DTD constraints
- The role of subject integration in steam Education
- Questions 101 to 200 of the national information security grade examination nisp level 1 question bank (1)
- Restrict input type (multiple methods)
- Example of multipoint alarm clock
- Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
- Mysql5.6.36 tutorial
- Square array cyclic right shift
猜你喜欢

Carry out effective maker education courses and activities

Mt4/mql4 getting started to mastering EA tutorial lesson 5 - common functions of MQL language (V) - common functions of account information

Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language

Coding complexity C (n)

I spring and autumn web Penetration Test Engineer (elementary) learning notes (Chapter 3)

Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function
![[Oracle database] mammy tutorial Day11 numerical function](/img/75/6a4340a7e9c6ee5f75a95bb3b6747f.png)
[Oracle database] mammy tutorial Day11 numerical function

解析认知理论对创客教师实训的作用

同态加密的基本概念

Thread status (timed wait, lock blocking, infinite wait (key))
随机推荐
Dom4j+xpath parsing XML files
Installing SQL Server 2008 by image in Windows Service 2008
C # interface holding structure causes packing problem
Web Knowledge 2 (request+response)
The solution to the problem of the first screen picture loading flicker
多点闹钟实例
Calculation days ()
Summary of basic knowledge of Oracle database SQL statement III: data operation language (DQL)
邮件巨头曝严重漏洞,用户数据被窃取
. Net core technology stack website Collection
Three characteristics of concurrency 2-orderliness
开展有效的创客教育课程与活动
C# 接口持有结构体会导致装箱问题
Is pioneer futures safe? What are the procedures for opening futures accounts? How to reduce the futures commission?
成为一名卓越云架构师要具备的五项技能
Mt4/mql4 getting started to mastering EA tutorial lesson 3 - common functions of MQL language (III) - common functions of K-line value taking
Concatenate the specified character at the end of a number in a string
Chapter VIII web project testing (the end of this chapter)
Application of complex science in Maker Teaching Research
0 basic self-study STM32 (wildfire) -- what is a register?