- 博客(19)
- 收藏
- 关注
转载 Find Longest common string
动态规划法:用二维矩阵来的每个元素来代表两个字符串的字符匹配情况,LCS[i, j]= LCS[i-1, j-1] + 1 , if X[i-1] == Y[J-1].LCS[i, j] =0, everything else每一个元素记载着两个字符串的相似程度,而且每个元素只需关心上一个元素的值来计算字符串比较的累计情况。实现代码: ...
2018-03-18 08:39:00 105
转载 Dijkstra 算法
TipsDijstra algorithm can help you to find all shortest path from start node to all other nodes.Core logiccalculate the shortest path from start node to all adjacent node.Get the ...
2018-03-15 14:04:00 85
转载 Adjacency matrix based Graph
InterfaceAddVertex(T data)AddEdge(int from, int to)DFSBFSMSTTopSortPrintGraphusing System;using System.Collections.Generic;using System.Linq;namespace TestCase1.Tes...
2018-03-11 09:43:00 121
转载 AVL Tree Deletion
Overview知识点:1. delete函数的signaturepublic AVLTreeNode Delete(AVLTreeNode node, int key)2. 算法,如何删除节点: // 如果左右节点都为空,node = null // 如果一个为空,另一个字节点不为空,把node节点替换成不为空的字节点 ...
2018-02-26 05:46:00 159
转载 Deepest left leaf node in a binary tree
Recursionselfcontained recursionglobal variables outside of recursionRecursion DesignWhenever reach to a qualified node, record the node reference and level for that nodeif meet ...
2018-02-26 05:27:00 78
转载 二叉搜索树(BST)的插入和删除递归实现
思路二叉搜索树的插入TreeNode InsertRec(rootNode, key) = if rootNode == NULL, return new Node(key) if key >= rootNode.data, rootNode.rightChild = InsertRec(rootNode.rightChild, key)...
2018-02-25 10:45:00 270
转载 AVL Tree Insertion
OverviewAVL tree is a special binary search tree, by definition, any node, its left tree height and right tree height difference is not more than 1. The purpose of AVL tree is to try best to re...
2018-02-20 03:22:00 558
转载 .Net memory management Learning Notes
Managed HeapsIn general it can be categorized into 1) SOH and 2) LOH. size lower than 85K will be in SOH, size larger than 85K will be in LOH.Small Object HeapGC will do 1) Mark 2) Sweep 3...
2018-02-19 05:05:00 92
转载 Heap Sort - recursion
Heap SortBuild a max heap using exsiting array, which is called HeapifySwap root with the last element, and re-Heapify the root nodeHeapifyHeapify(array, n, i) = 1) compare node[i] w...
2018-02-05 03:21:00 72
转载 外排序
排序分类如下:内排序基本排序 (冒泡,选择,插入)高级排序 (归并排序,快速排序, 堆排序)外排序外存和内存相结合的排序转载于:https://www.cnblogs.com/xuyanran/p/8376252.html...
2018-01-29 10:52:00 92
转载 Quick Sort
快排在大规模元素(》100)被证明几乎是效率最高的排序方法, 也是一种分而治之算法的一个典型应用。快排的思想是:1)每次选定一个元素作为pivot, 利用pivot对数组进行分区(partition)2) 大的放在pivot的后面,小的放在pivot前面3)递归的对新生成的两个分区进行快排代码如下: public class QuickSortCl...
2018-01-27 14:39:00 103
转载 Merge Sort
Merge Sort 的递归实现, 同时也是算法里面常见的分而治之方法。先放上一段分而治之的算法定义, 一张图胜过千言万语。sort 整个数组 = sort 前半个数组, then sort后半个数组, then merge两个有序数组。merge整个有序数组是非递归程序,输入有array本身,left, middle 和 right左半数组长度,有半数组...
2018-01-25 14:06:00 85
转载 中缀表达式和后缀表达式学习心得
中缀表达式(Infix expression)即符合a op b的格式, 后缀表达式(Post Fix expression)即符合a b op 的格式。为什么要有后缀表达式?原因在于后缀表达式可以很容易的被计算机理解。举个例子,a*(b+c)/d, 转化为后缀表达式是abc+*d/, 计算机会用栈来解释执行该表达式。如果我是计算机,对于后缀表达式输入,会做如下事情:co...
2018-01-16 13:13:00 460
转载 Post Order traverse binary tree using non-recursive way
Process analysis Stack = 5, Push 3, Stack = 5, 3. Pre = 5Current = 3, Pre = 5, Push 2 to the stack, stack = 5, 3, 2, Pre = 3Current = 2, Pre = 3, pop 2, PRINT 2, Stack = 5, 3....
2018-01-15 11:47:00 154
转载 Binary Search Tree Learning Summary
BST DefinitionBST is short for Binary Search Tree, by definition, the value of right node is always greater or equal to the root node, the value of left node is always less than the root node....
2018-01-14 09:00:00 72
转载 反转链表的递归与非递归实现
反转链表也是面试时常问到的题目,题目听上去很简单,想要快速正确的写出来,也确实需要很扎实的基本功。这类简单的题目既有非递归的实现方法,也有递归的实现方法。非递归实现非递归实现,模拟的是基本的手动操作, 访问链表中的每一个节点,但是同时要记住当前被访问节点的上一个和下一个节点。这三个指针构成了一个滑动的窗口,当前的值是滑动窗口的中心,上一个节点最终会变成新链表的头节点...
2018-01-07 08:27:00 77
转载 循环双向链表
第一次用C#描述链表,和大学时用C++ 描述链表的感觉很一致,用visual studio很快就可以实现单向链表,双向链表, 和循环链表。The reference type of C# is a key, and play the same role as pointer in C++.上一段自己写的循环链表代码,单元测试都已经通过。using System;usi...
2018-01-06 10:57:00 106
转载 Spell checker using hash table
Problem descriptionGiven a text file, show the spell errors from it. (https://www.andrew.cmu.edu/course/15-200/s06/applications/labs/lab3/)Psuedo CodeThe Dictionary Hash Table (Error Det...
2018-01-01 13:24:00 111
转载 HashTable
HashTable 主要包含:Hash(string key), 先计算hash后计算余数, 对于string而言,把每一位char的ASCII码叠加起来。 sum = sum*37 + char[i], sum%data.length, 要考虑负余数的情况Insert(string key), 调用hash()拿到index, 存值至bucketDelete(stri...
2017-12-30 01:11:00 70
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人