KMP算法(next数组) 二分查找(非递归) /** * 二分查找(非递归) * @param arr 从小到大的排序数组 * @param target 目标查找值 * @return */ public static int binarySearch(int[] arr,int target){ int left = 0; int right = arr.length - 1; while (left <= right){ int mid = (left + right )/2; if (…
Java数据结构和算法(四)赫夫曼树 数据结构与算法目录(https://www.cnblogs.com/binarylei/p/10115867.html) 赫夫曼树又称为最优二叉树,赫夫曼树的一个最主要的应用就是赫夫曼编码. 一.赫夫曼编码 can you can a can as a can canner can a can. 1.1 定长编码 99 97 110 32 121 111 117 32 99 97 110 32 97 32 99 97 110 32 97 115 32 97…