
0104【算法分析】
包含一些基础的算法
努力的阳光蓝孩
学习一时爽,一直学习一直爽
展开
-
【设计之美】02 兔子数列
一、递归求解阶乘1、时间复杂度O(n) 空间复杂度O(n)2、递推 回归3、T(n) = T(n-1) + 14、复杂度: 直接能看出、假设运行m次 求m 、分析的结果二、魔鬼序列1、棋盘的麦子棋盘上的麦子,第一个格子里放一粒麦子,在第二个格子里放两粒,在第三个格子里放四粒,在第四个格子里放8粒,以此类推,每一个格子都是前一格子的两倍。放慢64个格子需要多少?1) S = 1 + 2^1 + 2^2 + 2^3 + ....+ 3^632) 2S = 2^ + ...+ 2^64原创 2020-10-04 18:13:30 · 379 阅读 · 0 评论 -
【算法之美】01 算法初识
一、为什么要学算法?1、百度百科2、维基百科算法(algorithm),在数学(算学)和计算机科学之中,为任何一系列良定义的具体计算步骤[1],常用于计算、数据处理和自动推理。作为一个有效方法,算法被用于计算函数[2],它包含了一系列定义清晰的指令[3],并可于有限的时间及空间内清楚的表述出来[4]。算法中的指令描述的是一个计算,当其运行时能从一个初始状态和初始输入(可能为空)开始,[5]经过一系列有限[6]而清晰定义的状态最终产生输出[7]并停止于一个终态。一个状态到另一个状态的转移不原创 2020-10-04 15:43:02 · 202 阅读 · 0 评论 -
算法笔记十三、斐波那契数列查找算法代码
package com.hao.firstdemo.datastruct.search;import java.util.Arrays;/** * @author haoxiansheng * @data 2020/5/9 22:40 */public class FibonacciSearch { public static int maxSize = 20; public static void main(String[] args) { int[].原创 2020-05-09 23:48:47 · 237 阅读 · 0 评论 -
算法笔记十二、快速排序代码
package com.hao.firstdemo.datastruct.sort;import java.util.Arrays;/** * @author haoxiansheng * @data 2020/5/8 7:00 */public class QuickSort { public static void main(String[] args) { int[] arr = {1, 8, 10, 46, 9, 3}; quickSort(.原创 2020-05-09 22:24:06 · 121 阅读 · 0 评论 -
算法笔记十一、二分查找代码
package com.hao.firstdemo.datastruct.search;import java.util.ArrayList;/** * @author haoxiansheng * @data 2020/5/9 20:20 */public class BinarySearch { public static void main(String[] args) { int arr[] = {1, 2, 3, 4, 52, 99, 99}; .原创 2020-05-09 22:10:41 · 119 阅读 · 0 评论 -
算法笔记十、线性查找代码
package com.hao.firstdemo.datastruct.search;/** * @author haoxiansheng * @data 2020/5/9 19:45 */public class SeqSearch { public static void main(String[] args) { int arr[] = {1, 9, 11, -1, 34, 89}; int index = seqSearch(arr, 11);.原创 2020-05-09 22:09:52 · 171 阅读 · 0 评论 -
算法笔记九、基数排序代码
package com.hao.firstdemo.datastruct.sort;import java.util.Arrays;/** * @author haoxiansheng * @data 2020/5/9 8.40 */public class RadixSort { public static void main(String[] args) { int arr[] = {53, 3, 542, 748, 14, 214}; Syst.原创 2020-05-09 22:08:59 · 186 阅读 · 0 评论 -
算法笔记八、插入查找代码
package com.hao.firstdemo.datastruct.search;/** * @author haoxiansheng * @data 2020/5/9 21:10 */public class InsertValueSearch { public static void main(String[] args) { int[] arr = new int[100]; for (int i = 0; i < 100; i++) .原创 2020-05-09 22:06:27 · 145 阅读 · 0 评论 -
算法笔记七、归并排序代码实现
package com.hao.firstdemo.datastruct.sort;import java.util.Arrays;/** * @author haoxiansheng * @data 2020/5/8 21:44 */public class MergeSort { public static void main(String[] args) { int[] arr = {8, 4, 5, 7, 1, 3, 6, 2}; int[].原创 2020-05-08 23:14:58 · 112 阅读 · 0 评论 -
算法笔记六、希尔排序代码
package com.hao.firstdemo.datastruct.sort;import java.util.Arrays;/** * @author haoxiansheng * @data 2020/5/7 23:00 */public class ShellSort { public static void main(String[] args) { ...原创 2020-05-08 08:54:18 · 119 阅读 · 0 评论 -
算法笔记五、插入排序代码
package com.hao.firstdemo.datastruct.sort;/** * @author haoxiansheng * @data 2020/5/7 22:30 */public class InsertSort { public static void main(String[] args) { int[] arr = {1, 8, 9...原创 2020-05-07 23:20:19 · 110 阅读 · 0 评论 -
算法笔记四、选择排序代码
package com.hao.firstdemo.datastruct.sort;/** * @author haoxiansheng * @data 2020/5/7 22:00 */public class SelectSort { public static void main(String[] args) { int [] arr = {1, 8,...原创 2020-05-07 23:17:20 · 109 阅读 · 0 评论 -
算法笔记三、冒泡排序代码
package com.hao.firstdemo.datastruct.sort;/** * @author haoxiansheng * @data 2020/5/7 */public class BubbleSort { public static void main(String[] args) { int [] arr = {1, 6, 10, 7,...原创 2020-05-07 09:19:03 · 125 阅读 · 0 评论