
Algorithm
wengyupeng
在等待中爆发
展开
-
1. 图解-直接插入排序
1. 思想 直接插入排序就是 打牌中抓牌插入的过程。(一般人都会整理为从小到大的序列) 思想:按照数据的大小插入到有序队列的合适位置。 2. 图解过程例1例2 3. 算法分析 排序类别 排序方法 时间复杂度 空间复杂度 ...原创 2018-11-19 14:22:47 · 411 阅读 · 0 评论 -
二叉排序树相对哈希表的优点 Advantages of Binary Search Tree over Hash Table
1. Binary Search Trees (reference-based) are memory-efficient. They do not reserve more memory than they need to. For instance, if a hash function has a range R(h) = 0...100, then you need to a...转载 2018-12-17 22:46:11 · 500 阅读 · 0 评论 -
图解—创建堆
转自: https://blog.youkuaiyun.com/u013254061/article/details/52514599 一.堆堆数据结构是一种数组对象,它可以被视为一棵完全二叉树结构。它的特点是父节点的值大于(小于)两个子节点的值(分别称为大顶堆和小顶堆)。 二.堆的创建过程给定n个数,从n/2个节点开始,依次构建堆,直到第一个节点。举例: 给定数组{5,23,3...转载 2018-12-17 12:38:49 · 2509 阅读 · 0 评论 -
渐进性分析(asymptomatic analysis)& 大O的数学定义&时间复杂度
一、什么是渐进性分析? 假设同一个任务,有2种算法, 如何去找出那个更好?一个简单的办法——用两个程序实现这两种算法,然后输入不同的数据,在你电脑上运行这两个程序,看看那个需要的时间更少。 用这种方法分析算法,有很多问题。1. 对一些输入,可能第一个性能更好;对另外一些,可能第二更好2. 对一些输入,第一个算法在一台机器上表现更好,另外一个算法在其它的机器上更好。 渐进...原创 2018-12-16 19:23:23 · 6723 阅读 · 1 评论 -
图解拓扑排序(Topological sort)
一、什么是拓扑排序 下图就是拓扑排序 拓扑排序其实是一个线性排序。——若图中存在一条有向边从u指向v,则在拓扑排序中u一定出现在v前面。维基百科拓扑排序的定义:a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such th...原创 2018-12-14 17:16:27 · 5920 阅读 · 0 评论 -
图解-迪杰斯特拉算法(找最短路径)Dijkstra's Algorithm (finding shortestpaths)
转自:http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/11-Graph/dijkstra2.html 一. 图解迪杰斯特拉 Before showing you the pseudo code, I will first execute the Dijkstra's Algorithm on the followin...转载 2018-12-14 10:10:46 · 2677 阅读 · 0 评论 -
快速选择排序 Quick select 解决Top K 问题
1. 思想 Quick select算法通常用来在未排序的数组中寻找第k小/第k大的元素。 Quick select和Quick sort类似,核心是partition。 1. 什么是partition?(如下图,选44为pivot,把数组分为2部分,左边比44小,右边比44大) 从数组中选一个数据作为pivot,根据每个数组的元素与该pivot的大小将整...原创 2018-12-03 18:07:49 · 8345 阅读 · 0 评论 -
M个苹果放在N个盘子里,有多少种不同的放法
1. 问题 M个同样的苹果放N个同样的盘子,允许有盘子空着, 问有多少种放法? 2.分析 令f(m,n)表示m个苹果放到n个盘子里有多少种放法,下面分类讨论: m<n时,至少有n-m个盘子空着(这些空盘子并不影响最后的结果,因为每种方法都带有着些空盘子)。只考虑m个苹果放m个盘子 f(m,n)=f(m,m) m>n时,按是否有空盘子 ...原创 2018-12-03 11:33:54 · 8472 阅读 · 0 评论 -
图解-堆排序 in-place Heap Sort
转自:http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/9-BinTree/heap-sort2.html Short-coming of the previous "simple" Heap Sort algorithm Consider the (previously discussed) simple Hea...转载 2018-12-04 18:10:50 · 1002 阅读 · 0 评论 -
图解-堆删除节点
转自:http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/9-BinTree/heap-delete.html Deleting a specific node from a Heap Problem description: You are given a heap...转载 2018-12-04 18:06:34 · 2351 阅读 · 1 评论 -
图解-堆插入节点
转自:http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/9-BinTree/heap-insert.html Inserting a value into a Heap Problem description: You are given a heap. F...转载 2018-12-04 18:04:35 · 779 阅读 · 0 评论 -
4.图解-折半插入排序 Binary insert sort
1. 思想 折半插入排序是对直接插入排序的改进。 直接插入排序就是不断的依次将元素插入前面已经排好序的序列中。 由于前半部分为已经排好的序列,这样就不用按顺序依次比较寻找插入点,而是采用折半查找的方法来加快寻找插入点2.图解-折半查找 将关键字 7 折半查找插入到 numbersArray。 查找过程如上图int[] numbersArray = {1,3...原创 2018-11-29 16:47:28 · 1919 阅读 · 1 评论 -
卡特兰数(catalan number)
1. 卡特兰数是什么 卡塔兰数是组合数学中一个常在各种计数问题中出现的数列。公式为 : 前几项为 (n=0,1,2,3,4,5时): 1, 1, 2, 5, 14, 42 n=3时,C 3=5 2. 应用2.1 一个栈的进栈次序为1、2、3……n。有多少种不同的出栈次序? 当 时,有如下5种不同的入出栈顺序 ...原创 2018-11-23 11:18:25 · 339 阅读 · 0 评论 -
3. 图解-什么是堆
1. 完全二叉树 Complete binary tree Complete binary tree = a binary tree where all levels, except possibly the last level are completely filled with nodes Furthermore: the last level has all its n...翻译 2018-11-22 16:05:58 · 336 阅读 · 0 评论 -
2. 图解-选择排序
1. 思想 每一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置 2. 图解过程每一趟选最小的。例1: 例2:3.CODE in JAVApublic class SelectionSort { public static void selectionSort(int[] a) { int n =...原创 2018-11-19 20:30:23 · 191 阅读 · 0 评论 -
Precision,Recall and F1-measure 准确率、召回率以及综合评价指标
通俗易懂,故转一下。 转自:http://www.cnblogs.com/bluepoint2009/archive/2012/09/18/precision-recall-f_measures.html在信息检索和自然语言处理中经常会使用这些参数,下面简单介绍如下:1.准确率与召回率(Precision & Recall)我们先看下面这张图来加深对概念的理解,然...转载 2018-07-28 13:56:54 · 648 阅读 · 0 评论