算法
文章平均质量分 78
肉包毕业啦
这个作者很懒,什么都没留下…
展开
-
快速排序
采用了一种分治的思想 1.分解 在r[low...high]中选择一个pivot ,将其分为左右两个区间 并使左区间内的key均小于pivot.key,右区间内的key均大于pivot.key 注意: 划分的关键是要求出基准记录所在的位置pivotpos。划分的结果可以简单地表示为(注意pivot=R[pivotpos]): R[low..pivotpos-1].转载 2014-01-15 22:10:53 · 425 阅读 · 0 评论 -
关于二叉树
public class BinaryTree> { private static class BinaryNode{ BinaryNode(T element){ this.element=element; } BinaryNode(T element,BinaryNode lt,BinaryNode rt) { this.element=element;原创 2014-03-24 12:42:23 · 434 阅读 · 0 评论 -
backtracking 回溯法题目总结
最近在Leetcode上做了几道关于回溯法的算法题。 虽说回溯的思想很简单,按深度优先算法,遍历解空间树,逐步探索。发现探索到某一步时,不符合描述,则退回到上一步(即回溯),重新选择分支。但实际操作起来,却是有些难度。。 1. 组合问题 Combinations Given two integers n and k, return all possible combinati原创 2015-07-19 09:37:43 · 943 阅读 · 0 评论 -
leetcode wordsearch II
做完word search之后,有一个类似的问题 word search II 与I不同的是,一为输入一个单词,判断单词是否在board里; II 中输入的是一组单词,返回在board中的所有单词。 Given a 2D board and a list of words from the dictionary, find all words in the board. Each w原创 2015-07-23 16:17:49 · 408 阅读 · 0 评论