- 博客(38)
- 收藏
- 关注
原创 8数码问题
初始状态的步数就算1输入:第一个3*3的矩阵是原始状态,第二个3*3的矩阵是目标状态。输出:移动所用最少的步数Input2 8 31 6 47 0 51 2 38 0 47 6 5Output6第一个代码超时了#include<stdio.h>#include<string>#include<cst...
2020-03-03 13:14:46 677
转载 Design and Analysis of Algorithms (B-Trees)
B-TreesB-Trees are tree data structures that store sorted data. B-Trees can be seen as a generalization of Binary Search Trees where nodes can have more than one key/value and more than two children...
2018-09-21 21:41:12 223
原创 The FFT Algorithm
Fourier Transform(DFT)There is an entire theory of expanding functions in terms of sin(kwx) called Fourier Analysis. We are interested in extracting frequencies from DATA.Fast Fourie...
2018-09-21 19:11:56 357
转载 Design and Analysis of Algorithms (Divide & Conquer: FFT)
Polynomial operations and representationsA polynomial A(x) can be written in the following form: The degree of A is n-1;Operations on polynomialsEvaluation: Given a polynomial A(x) and a num...
2018-09-20 16:11:12 331
转载 Artificial Intelligence (Search: Games, Minimax, and Alpha-Beta)
How might be possible for a computer to play chess?Move If Then Rules Look Ahead & Evaluate British Museum Look ahead as far as possibleMinimax IdeaThe player at the top would like to dri...
2018-09-07 17:06:30 294
转载 Design and Analysis of Algorithms (Divide & Conquer: Smarter Interval Scheduling, Master Therorem)
Weighted Interval SchedulingConsider requests 1,. . . ,n. For request i, s(i) is the start time and f(i) is the finish time, s(i) < f(i). Two requests i and j are compatible if they don’t overlap...
2018-09-07 11:04:36 554
转载 Design and Analysis of Algorithms (Divide & Conquer: Convex Hull, Median Finding)
ParadigmGiven a problem of size n divide it into subproblems of size n, a ≥ 1, b > 1. Solve each subproblem recursively. Combine solutions of subproblems to get the overall solution.T(n) = aT(...
2018-09-06 20:25:45 335
转载 Design and Analysis of Algorithms (Interval Scheduling)
Very similar problems can have different complexity. Recall:P: a class of problems solvable in polynomial time. O( ) for some constant k. NP: a class of problems verifiable in polynomial time. Ham...
2018-09-05 15:57:23 452
转载 Introduction to Algorithms (Principles of Algorithm Design)
Principles of Algorithm DesignWhen you are trying to design an algorithm or a data structure, it’s often hard to see how to accomplish the task. The following techniques can often be useful:Experi...
2018-08-31 15:58:04 447
原创 Introduction to Algorithms (Rolling Hashes, Amorted Analysis)
Rolling HashesWe have a big document, aka a long string, and we're trying to find a small string inside it.N: "the fox is in the hat"k: "the" -> h(k)w: "the" h(w) == h(k) &&am...
2018-08-30 21:27:00 231
转载 Search (Artificial Intelligence)
Search is about choiceA very important principle of problem-solving. A that is that if you want to solve a problem, the easiest way to solve a problem is, usually, ask somebody who knows the answer....
2018-08-29 15:59:15 550
原创 Reasoning: Goal Trees and Rule-Based Expert system
Simon's Ant“An ant, viewed as a behaving system, is quite simple. The apparent complexity of its behavior over time is largely a reflection of the complexity of the environment in which it finds its...
2018-08-24 20:55:01 326
转载 Reasoning: Goal Trees and Problem Solving(Artificial Intelligence)
problem reductionAND/OR treegoal tree
2018-08-20 17:22:25 212
转载 Introduction and scope (Artificial Intelligence)
Algorithms enabled by constraints exposed by representations that support models targeted at thinking, perception, and actionGenerate and TestRumpelstiltskin Principle says once you can name somet...
2018-08-19 21:32:23 414
转载 Background for computer networks
The ProblemMaking two computers hooked together "talk" to each other.Physical media transmit analog signals, not bits. We, therefore, need a way of converting from bits to signals. This is typical...
2018-08-14 21:24:58 304
转载 Packet Switching
This article discusses different ways of interconnecting links of the same kind to build a simple network. To do this, we will use a device called a switch, and discuss several different ways of switc...
2018-08-14 15:02:39 1586
转载 Introduction to Algorithms (Computational Complexity)
Def:P = {problems solvable in polynomial time} Exp = {problems solvable in exponential time} R = {problems solvable in finite time}Halting Problem:Given a computer program, does it ever halt (s...
2018-08-03 11:55:30 462
转载 Introduction to Algorithms (DP IV: Guitar Fingering, Tetris, Super Mario Bros)
Piano/Guitar Fingeringgiven musical piece to play, say sequence of n (single) notes with right hand fingers 1, 2, . . . , F = 5 for humans metric d(f, p, g, q) of difficulty going from note p with...
2018-08-03 10:33:35 254
转载 Introduction to Algorithms (DP III: Parenthesization, Edit distance, Knapsack)
* Subproblems for strings/sequencessuffixes x[i:] i prefixes x[:i] i substrings x[i:j] i < jParenthesizationOptimal evaluation of associative expression A[0] · A[1] · · · A[n − 1] — e...
2018-08-02 16:07:05 249
转载 Introduction to Algorithms (Dynamic Programming II: Text Justification, Blackjack)
5 easy steps to DPdefine subproblems #subproblems guess (part of the solution) #choices for guess relate subproblem solutions #time/subproblems recursive & memoize or build DP table bottom-up...
2018-08-02 10:33:42 430
转载 Introduction to Algorithms (Dynamic Programming I: Fibonacci, Shortest Paths)
Dynamic Programming (DP)A big idea, hard, yet simpleA powerful algorithmic design technique A large class of seemingly exponential problems has a polynomial solution (“only”) via DP Particularly...
2018-08-01 22:11:57 289
转载 Introduction to Algorithms (Speeding up Dijkstra)
Bi-Directional SearchNote: Speedup techniques covered here do not change worst-case behavior, but reduce the number of visited vertices in practice.Bi-D Search Alternate forward search from s, b...
2018-07-31 16:08:32 239
转载 Introduction to Algorithms (Bellman-Ford)
Generic S.P. AlgorithmInitialize: for v in V: d[v] ← ∞ Π[v] ← NIL d[s] ← 0Main: Repeat ...
2018-07-31 10:53:49 365
转载 Introduction to Algorithms (Dijkstra)
Relaxation is SafeLemma: The relaxation algorithm maintains the invariant that d[v] ≥ δ(s, v) for all v ∈ V.Proof: By induction on the number of steps.Consider RELAX(u, v, w). By induction d[u] ...
2018-07-30 16:59:55 353
转载 Introduction to Algorithms (Insertion Sort, Merge Sort)
The problem of sortingInput: array A[1…n] of numbers.Output: permutation B[1…n] of A such that B[1] ≤ B[2] ≤ … ≤ B[n] .Why SortingObvious applications Problems that become easy once items a...
2018-07-30 15:05:37 183
转载 Introduction to Algorithms (Models of Computation)
What's an algorithm?Computational procedure to solve a problem Mathematical abstraction of computer programModel of computation specifieswhat operations an algorithm is allowed cost (time, sp...
2018-07-30 14:21:37 287
转载 Introduction to Algorithms (Single-Source Shortest Paths Problem)
MotivationThe shortest way to drive from A to B Google maps “get directions”Formulation: Problem on a weighted graph G(V, E), W: E → RTwo Algorithms: Dijkstra O(V log V + E) assumes non-negative...
2018-07-30 11:30:06 237
转载 Introduction to Algorithms (Depth-First Search, Topological Sort)
Depth-First Search (DFS)recursively explore graph, backtracking as necessaryparent = {s: None}DFS-Visit(V, Adj, s): for v in Adj[s]: if v not in parent parent[v] = s...
2018-07-29 21:30:21 188
转载 Introduction to Algorithms (Breadth-First Search)
Graph SearchExplore a graphfind a path from start vertex s to the desired vertex visit all vertices or edges of graph or only those reachable from sApplicationsweb crawling social networking...
2018-07-29 18:40:27 257
转载 Introduction to Algorithms (Square Roots, Newton's Method)
Error Analysis of Newton's MethodSuppose Then, Therefore, Multiplication AlgorithmsNaive Divide & Conquer method: Θ(d^2) time Karatsuba: Θ(d^1.584...) Toom-Cook generalizes Karatsuba (...
2018-07-29 11:50:51 251
转载 Introduction to Algorithms (Integer Arithmetic, Karatsuba Multiplication)
IrrationalsCatalan numbersSet P of balanced parentheses strings is recursively defined as:λ ∈ P (λ is the empty string) If α, β ∈ P, then (α)β ∈ PEvery nonempty balanced paren string can be ob...
2018-07-28 20:22:27 223
转载 Introduction to Algorithms (Open Addressing, Cryptographic Hashing)
Open addressingAnother approach to collisionsno chaining; instead all items stored in a table one item per slot ⇒ m ≥ n hash function specifies the order of slots to probe (try) for a key (for i...
2018-07-28 13:38:35 253
转载 Introduction to Algorithms (Table Doubling, Karp-Rabin)
How Large should Table be?want m = Θ(n) at all timesIdeaStart small (constant) and grow (or shrink) at necessaryRehashingTo grow or shrink table hash function must changemust rebuild hash t...
2018-07-27 20:54:04 548
转载 Introduction to Algorithms (Hashing with Chaining)
Dictionary:Maintain a set of items each with a keyinsert(item) delete(item) search(key): return the item with given key or report doesn't existMotivationDictionaries are perhaps the most popu...
2018-07-27 14:39:48 311
转载 Introduction to Algorithms (Counting Sort, Radix Sort, Lower Bounds for Sorting)
Comparison modelall input items are black boxes (ADTS) only operations allowed are comparisons (<,<=,>,>=) time cost = # comparisonsDecision treeany comparison algorithm can be vie...
2018-07-26 17:14:10 227
转载 Introduction to Algorithms (AVL Trees, AVL Sort)
Recall: Binary Search Treesrooted binary tree each node has: key left pointer right pointer parent pointer BST property the height of node = length of the longest downward path to a leaf...
2018-07-26 15:22:50 277
转载 Introduction to Algorithms (Binary Search Trees, BST Sort)
Runway Reservation SystemAirport with single runway Reservations for future landings Reserve request specifies landing time t Add t to the set R if no other landings are scheduled within k minu...
2018-07-26 10:51:11 354
转载 Introduction to Algorithms (Heaps and Heap Sort)
Priority QueueA data structure implementing a set S of elements, each associated with a key, supporting the following operations:insert(S, x): insert element x into set S max(S): return element ...
2018-07-25 22:15:58 202
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人