大数据开发-01
来源:互联网 发布:star法则简历模板java 编辑:程序博客网 时间:2024/04/30 16:51
1、位操作,显示二进制方法:
public static void toBinary(int num) {
int[] arr = new int[32];
// 0000 0010 & 0000 0001 ===> 0
for(int i = 31; i >= 0; i--) {
arr[i] = (num >> i) & 1;
System.out.print(arr[i]);
}
}
2、插入排序法
public
static
int
[] doInsertionSort(
int
[] input){
int
temp;
for
(
int
i =
1
; i < input.length; i++) {
for
(
int
j = i ; j >
0
; j--){
if
(input[j] < input[j-
1
]){
temp = input[j];
input[j] = input[j-
1
];
input[j-
1
] = temp;
}
}
}
return
input;
}
3、冒泡排序法,跟相邻的值进行比较,替换
for (int m = n; m >= 0; m--) { for (int i = 0; i < n - 1; i++) { k = i + 1; if (array[i] > array[k]) { swapNumbers(i, k, array); } } printNumbers(array); }
}
4、选择排序法
for(int i = 0; i < data.length; i++) {//假设第一个数十最小数;int index = i;for(int j = i + 1; j < data.length; j++) {if (data[j] < data[index]) {//如果index = j;}temp = data[index];data[index] = data[i];data[i] = temp;}}
private
void
quickSort(
int
lowerIndex,
int
higherIndex) {
int
i = lowerIndex;
int
j = higherIndex;
// calculate pivot number, I am taking pivot as middle index number
int
pivot = array[lowerIndex+(higherIndex-lowerIndex)/
2
];
// Divide into two arrays
while
(i <= j) {
/**
* In each iteration, we will identify a number from left side which
* is greater then the pivot value, and also we will identify a number
* from right side which is less then the pivot value. Once the search
* is done, then we exchange both numbers.
*/
while
(array[i] < pivot) {
i++;
}
while
(array[j] > pivot) {
j--;
}
if
(i <= j) {
exchangeNumbers(i, j);
//move index to next position on both sides
i++;
j--;
}
}
// call quickSort() method recursively
if
(lowerIndex < j)
quickSort(lowerIndex, j);
if
(i < higherIndex)
quickSort(i, higherIndex);
}
private
void
exchangeNumbers(
int
i,
int
j) {
int
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
0 0
- 大数据开发-01
- 大数据开发视频
- 大数据-开发利器
- 大数据开发进阶
- 大数据-开发利器
- 大数据开发初探
- 大数据开发例子
- 大数据-开发利器
- 大数据开发工具
- 大数据平台开发高级工程师
- 对大数据开发经验
- 大数据开发必备工具
- 趋势分析:大数据开发
- 大数据开发基础上笔记
- 大数据项目开发步骤
- 大数据开发之路
- 大数据开发学习路线图
- 大数据开发平台-数据同步服务
- DTW算法java版
- 在URL中传带百分号%的参数的两种方法:直接传编码或使用encodeURI
- Apache Sqoop使用
- php的几个面试题
- Day43: Miss a job interview
- 大数据开发-01
- 爬虫 只爬取网页部分内容的问题
- VC++6.0下基于MFC的串口通信助手实现
- thrift JAVA服务端 python客户端的实现
- cdecl函数返回值传参方式
- C++输出前n个数中的素数
- 进程描述和控制
- JavaScript基础知识
- Android如何运用Android studio进行安卓APP内存泄漏的检测