An important task when processing arithmetic expressions is to mach delimiters. We can use Stack to solve this problem. def is_matched(expr): left='({[' right=')}]' S=ArrayStack() for c in expr: if c in left: S.push(c) elif c in right: if S.is_empty(…
排序稳定:如果两个数相同,对他们进行的排序结果为他们的相对顺序不变.例如A={1,2,1,2,1}这里排序之后是A = {1,1,1,2,2} 稳定就是排序后第一个1就是排序前的第一个1,第二个1就是排序前第二个1,第三个1就是排序前的第三个1.同理2也是一样.不稳定就是他们的顺序与开始顺序不一致. 原地排序:指不申请多余的空间进行的排序,就是在原来的排序数据中比较和交换的排序.例如快速排序,堆排序等都是原地排序,合并排序,计数排序等不是原地排序.总体上说,排序算法有两种设计思路,一种是基于比较…
Source, git Heap is a data structure that can fundamentally change the performance of fairly common algorithms in Computer Science. The heap data structure is called a heap because it satisfies the heap property. The heap property states, that if P i…
For example we have an array of words: [car, done, try, cat, trie, do] What is the best data structure to store the data and easy for search? We can use Trie data structure, it is a tree, but not a binary tree. The reuslts of constructing a tree by u…
A graph is a data structure comprised of a set of nodes, also known as vertices, and a set of edges. Each node in a graph may point to any other node in the graph. This is very useful for things like describing networks, creating related nonhierarchi…
Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5739 Description Professor Zhang has an undirected graph G with n vertices and m edges. Each vertex is attached with a weight wi. Let Gi be the graph after deleting the i-th vertex from graph G. Pro…
题目链接: Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 207    Accepted Submission(s): 41 Problem Description Mr. Frog learned a basic data structure recently, which is called…
Data Structure Problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/483 Description Data structure is a fundamental course of Computer Science, so that each contestant is highly likely to solve this data structu…
Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 872    Accepted Submission(s): 236 Problem Description Mr. Frog learned a basic data structure recently, which is called stac…