随笔分类 -  数据结构与算法

摘要:```js // 最大公约数算法 // 1. a % b 进行取余运算 // 2. 将被取余数与余数进行再次取余运算 // 3. 直到a % b为0时停止取余运算 // 4. 将取余为0时的被取余数返回即是最大公约数 function gcd(a, b) { if (b === 0) { return a; } return gcd(b, a % b); }// 求多... 阅读全文
posted @ 2019-12-01 12:15 pluscat 阅读(752) 评论(0) 推荐(0)
摘要:密码学基础总结 阅读全文
posted @ 2019-10-29 23:15 pluscat 阅读(344) 评论(0) 推荐(0)
摘要:bitmap实现原理 add操作 js //得到第几行索引 let byteIndex = Math.floor(k / 16); //得到第几列的索引 let bitIndex = k % 16; //将1移动到索引的位置并修改该位置 this.blk[byteIndex] = this.blk[ 阅读全文
posted @ 2019-10-27 18:59 pluscat 阅读(242) 评论(0) 推荐(0)
摘要:simhash 在simhash中处理一个文本的步骤如下: 第一步,分词: 对文本进行分词操作,同时需要我们同时返回当前词组在文本内容中的权重(这基本上是目前所有分词工具都支持的功能)。 第二步,计算hash: 对于每一个得到的词组做hash,将词语表示为到01表示的bit位,需要保证每个hash结 阅读全文
posted @ 2019-10-26 22:42 pluscat 阅读(3534) 评论(0) 推荐(0)
摘要:计算当前日期星座 | 起始月份 | 号数| 星座 | 结束月份 | 号数 | 时间区间| | | | | | | | | 12 | 22 | 摩羯座 | 1 | 19 | 12/22 1/19| | 1 | 20 | 水瓶座 | 2 | 18 | 1/20 2/18 | | 2 | 19 | 双鱼座 阅读全文
posted @ 2019-09-14 23:37 pluscat 阅读(717) 评论(0) 推荐(0)
摘要:牛顿迭代法 利用牛顿迭代法求解平方根 阅读全文
posted @ 2019-08-30 00:47 pluscat 阅读(1025) 评论(0) 推荐(0)
摘要:数独 游戏规则 检查算法 数独自动求解 js const NOTASIGN = 0 function usedInCol(map,row,num){ for(let col = 0; col 阅读全文
posted @ 2019-05-17 23:17 pluscat 阅读(1274) 评论(0) 推荐(0)
摘要:迷宫找出口 js function isSafe(maze,x,y){ if(x = 0 && y = 0 && x 阅读全文
posted @ 2019-05-17 23:16 pluscat 阅读(196) 评论(0) 推荐(0)
摘要:初始化地图 js function initMaze(r,c){ let row = new Array(2 r + 1) for(let i = 0; i { const visited = [], key = [], parent = []; let {length} = graph; for( 阅读全文
posted @ 2019-05-16 21:50 pluscat 阅读(2339) 评论(0) 推荐(0)
摘要:```js class TrieNode { constructor(data){ this.data = data this.children = new Array(26) this.isEndingChar = false this.text = '' } } class TrieTree { cons... 阅读全文
posted @ 2019-05-05 16:05 pluscat 阅读(202) 评论(0) 推荐(0)
摘要:AC自动机 js class ACNode { constructor(data){ this.data = data this.isEndingChar = false this.children = new Map() this.length = 0 this.fail = null } } c 阅读全文
posted @ 2019-05-04 23:41 pluscat 阅读(351) 评论(0) 推荐(0)
摘要:最短编辑距离 js function levenshteinDistance(a,b){ //生成表 const distanceMatix = Array(a.length + 1).fill(null).map(() = Array(b.length + 1).fill(null)) //第一行 阅读全文
posted @ 2019-05-03 13:13 pluscat 阅读(449) 评论(0) 推荐(0)
摘要:朴素匹配算法 KMP算法 字符串前后缀 字符关系 执行过程 js //i指针不必回溯 //next[j]表示回溯位置 / 规则1:没有公共前后缀的情况,匹配失败时j = 0去匹配 s: a b (c) d e f g t: a b (d) t串中a与后边的bd串都不相等,在d匹配c失败时,可以知道t 阅读全文
posted @ 2019-02-03 20:19 pluscat 阅读(399) 评论(0) 推荐(0)
摘要:创建队列 使用ES6改造 最小优先队列 js function PriorityQueue(){ let items = [] function QueueElement(element,priority){ this.element = element this.priority = priori 阅读全文
posted @ 2019-01-28 20:26 pluscat 阅读(1848) 评论(0) 推荐(0)
摘要:实现栈结构 ES6改造 进制转换 平衡圆括号 js function balancedSymbols(symbols){ const stack = new Stack() const opens = const closers = let balanced = true let index = 0 阅读全文
posted @ 2019-01-27 20:24 pluscat 阅读(3376) 评论(0) 推荐(0)