笔记
IncludeLayout
是个立志要全栈的安卓小菜鸡
展开
-
希尔排序
//希尔排序 public void shellSort(int a[], int n) { int i, j, gap; for (gap = n / 2; gap > 0; gap = gap / 2) { for (i = 0; i < gap; i++) { for (j = i + gap; j原创 2017-08-15 12:01:12 · 159 阅读 · 0 评论 -
直接插入排序
private static void insertSort(int a[],int n){ int j,k; for(int i=1;i<n;i++){ for(j=i-1;j>=0;j--){ if (a[j]<a[i]) { break;原创 2017-08-14 22:54:20 · 182 阅读 · 0 评论 -
直接选择排序
之前写了关于直接插入排序的算法,注意区分。//直接选择排序 public void selectSort(int a[], int n) { int i, j, min; for (i = 0; i < n; i++) { min = i; for (j = i + 1; j < n; j++) {原创 2017-08-15 12:33:06 · 230 阅读 · 0 评论 -
关于ANR和Force Close
ANR: Application Not Responding 产生原因: 1.主线程(UI线程)响应用户操作事件时间超过5秒 2.BroadcastReceiver超过10秒钟任未执行完毕。 3.这种情况比较少见,Service的各个生命周期函数在特定时间(20秒)内无法完成处理。 避免方法: Android应用程序完全运行在一个独立的线程中。任何在主线程中运行的,需要消耗大量时间的操原创 2017-08-15 19:55:53 · 401 阅读 · 0 评论 -
堆排序笔记
首先堆排序使用的堆是二叉堆,二叉堆满足父结点的值总是大于等于(小于等于)子结点。 一般用数组来表示堆,若根结点存在序号0处, i结点的父结点下标就为(i-1)/2。i结点的左右子结点下标分别为2*i+1和2*i+2。 一般过程为: (1)将无序数组建堆,大顶堆或者小顶堆,根据排序需求 (2)删除堆顶元素,与最后一个元素互换位置,调整堆 结合二叉树和数组查看。 交换堆顶的元素和最后一个原创 2017-08-15 17:24:06 · 230 阅读 · 0 评论 -
LintCode 488快乐数
写一个算法来判断一个数是不是”快乐数”。一个数是不是快乐是这么定义的:对于一个正整数,每一次将该数替换为他每个位置上的数字的平方和,然后重复这个过程直到这个数变为1,或是无限循环但始终变不到1。如果可以变为1,那么这个数就是快乐数。样例 19 就是一个快乐数。1^2 + 9^2 = 828^2 + 2^2 = 686^2 + 8^2 = 1001^2 + 0^2 + 0^2 = 1笔者在进行原创 2017-09-15 19:39:29 · 609 阅读 · 0 评论 -
LintCode 671 循环单词
The words are same rotate words if rotate the word to the right by loop, and get another. Count how many different rotate word sets in dictionary.E.g. picture and turepic are same rotate words.["pictur原创 2017-09-15 19:56:02 · 796 阅读 · 0 评论 -
LintCode 647 Substring Anagrams
Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger t原创 2017-09-15 20:07:03 · 409 阅读 · 0 评论 -
整理排序算法 java
这是之前不知道什么时候从网上截图下来的,找不到出处了,超级棒的笔记冒泡排序//冒泡 public void bubleSort(int[] nums) { for (int i = 0; i < nums.length - 1; i++) {//循环n-1次,每循环完一次,冒泡得一个最大值 for (int j = 0; j < nums.length原创 2017-08-14 19:08:10 · 238 阅读 · 0 评论