data structure
gdtop818
这个作者很懒,什么都没留下…
展开
-
[Algorithm&Datastructure]Suffix Trie 后缀树代码实现
Give a linear-time algorithm to determine whether a text T is a cyclic rotation of another string T 0. For example, add is a cyclic rotation of dad. n = p = # length of T k = # matched chars S...原创 2018-05-14 08:46:01 · 331 阅读 · 0 评论 -
[princeton/Algotithm I/week1](1) UNION-FIND 并查集及代码实现
“ Algorithms + Data Structures = Programs. ” ‣ dynamic connectivity‣ quick find‣ quick union‣ improvements‣ applications1.Dynamic connectivity(动态连接)Given a set of N objects.Union command: ...原创 2018-06-11 17:15:36 · 592 阅读 · 0 评论 -
[princeton/Algotithm I/week1](3)Programming Assignment: Percolation
Programming Assignment 1: Percolation Write a program to estimate the value of the percolation threshold via Monte Carlo simulation. Environmentjava -algs4Command -d32 ...原创 2018-06-12 15:52:06 · 374 阅读 · 0 评论 -
[princeton/Algotithm I/week1](2)Interview Questions: Union–Find
Interview Questions: Union-FindHint: union−find.题目的意思是有一个包含n个成员的社交网络,日志文件log按照时间戳顺序存储了两个成员之间成为朋友的时间,共有m条记录。让我们设计一个算法来根据这个log文件来计算m个成员全部通过朋友关系连通的时间。这是个典型的并查集。思路是读取日志文件,遍历文件记录,逐条记录union。采用加权quic...原创 2019-02-18 00:03:50 · 877 阅读 · 1 评论 -
[princeton/Algotithm I/week1](4) Analysis of Algorithms
1.4 Analysis of Algorithms introduction observations mathematical models order-of-growth classifications theory of algorithms memory 1.4.1 Introduction:1. the cast...原创 2019-02-17 01:13:49 · 272 阅读 · 0 评论 -
[princeton/Algotithm I/week1](5)Interview Questions: Analysis of Algorithms
Interview Questions: Analysis of Algorithms《算法4》这本书提供的TwoSumFast解法为NlogN,ThreeSumFast解法为N2logN,根据课后练习,要实现3Sum复杂度为N2,建议先把2Sum复杂度实现为N。同时教材提示用排好序的数组可以实现复杂度N。没有发现排好序的数组对复杂度降至N有太大帮助,于是在网上搜索了下大家的做法。网上的大...翻译 2019-02-18 00:18:51 · 324 阅读 · 0 评论 -
[princeton/Algotithm I/week2](1) Stacks and Queues
Suggested Readings. Section 1.3 and 2.1 in Algorithms, 4th edition.Lecture: Stacks and Queues. We consider two fundamental data types for storing collections of objects: the stack and the queue. We ...原创 2019-02-18 00:33:38 · 200 阅读 · 0 评论 -
[princeton/Algotithm I/week2](2) Elementary Sorts
Suggested Readings. Section 1.3 and 2.1 in Algorithms, 4th edition.Lecture: Elementary Sorts. We introduce the sorting problem and Java's Comparable interface. We study two elementary sorting method...原创 2019-02-18 00:33:40 · 126 阅读 · 0 评论