Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
思路:建一个method来找某一个特定位置为中心的最长可能palindrome, 返回此长度。(注意有两种情况,长度为偶数和为奇数)。然后从s中心向两边开始依次找对应各个位置的最长长度,结果记录在数组num[i] 里,同时track 当前最长值,如果满足 2*middle - i < max/2 这个条件就没有必要继续了。
public class Solution {
public String longestPalindrome(String s) {
if (s == null)
return null;
if(s == "" || s.length()==1)
return s;
//create an array to store length of longest palindrome that centers at each position.
int[] num = new int[s.length()];
for(int i = 0; i<num.length; i++)
num[i] = 1;
int middle = s.length()/2;
//call method to calculate value of num[i], start with middle position;
num[middle] = findLongestPalindromethatCenterHere(s, middle);
num[0] = findLongestPalindromethatCenterHere(s, 0);
int index_max, max;
if(num[0]<num[middle])
{
index_max = middle;
max = num[middle];
}
else
{
index_max = 0;
max = num[0];
}
for(int i = middle+1; i<middle*2; i++)
{
num[i] = findLongestPalindromethatCenterHere(s, i);
if(num[i]>max)
{
max = num[i];
index_max = i;
}
num[middle*2-i] = findLongestPalindromethatCenterHere(s, middle*2-i);
if(num[middle*2-i]>max)
{
max = num[middle*2-i];
index_max = middle*2-i;
}
if(2*middle - i < max/2) //max already found here, no need to continue.
break;
}
if(num[index_max]%2 == 0)
return s.substring(index_max-num[index_max]/2+1, index_max+num[index_max]/2+1);
else
return s.substring(index_max-num[index_max]/2, index_max+num[index_max]/2+1);
}
//this method is to find length of possible longest palindrome that centers at specific position.
//be aware that there are two possibilities to address.
public int findLongestPalindromethatCenterHere(String s, int center)
{
//assume length of palindrome is a odd number.
int max1 = 1;
int start = center-1;
int end = center+1;
while(start>=0 && end<s.length())
{
if(s.charAt(start) == s.charAt(end))
max1 = max1+2;
else
break;
start--;
end++;
}
//assume length is an even number.
int max2 = 0;
start = center;
end = center+1;
while(start>=0 && end<s.length())
{
if(s.charAt(start) == s.charAt(end))
max2 = max2+2;
else
break;
start--;
end++;
}
return Math.max(max1, max2);
}
}
2014年3月30日星期日
2014年3月27日星期四
Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
思路:
刚开始我想着先找出每个位置之前的min,和每个位置之后的max。然后用一个双循环来算最大可能profit,结果超时了。
接着想想干脆先找出每个位置之前(包括此位置)交易所有可能最大profit值,记录为 max_left[i].
在从后往前找出每个位置之后交易所有可能最大profit值,记录为 max_right[i].
接下来就简单了。一个for loop 解决问题。
java版本,384 ms过,回头贴上code
| Accepted | 384 ms |
2014年3月22日星期六
[LeetCode] Binary Tree Level Order Traversal Solution
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example: Given binary tree{3,9,20,#,#,15,7},3 / \ 9 20 / \ 15 7return its level order traversal as:[ [3], [9,20], [15,7] ]用current,last两个ArrayList<TreeNode>来保存上一层和当前层node,ArrayList<Integer> temp保存last里每个node的值. 用isLeft还决定是否reverse temp, 然后加入res.public ArrayList<ArrayList<Integer>> zigzagLevelOrder(TreeNode root) {ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();if (root == null)return res;boolean isLeft = true;ArrayList<TreeNode> last = new ArrayList<TreeNode>();last.add(root);while(!last.isEmpty()){ArrayList<Integer> temp = new ArrayList<Integer>();ArrayList<TreeNode> current = new ArrayList<TreeNode>(); //current temp必须每次新建for(TreeNode node: last){temp.add(node.val);if(node.left!=null)current.add(node.left);if(node.right!=null)current.add(node.right);}if(!isLeft)Collections.reverse(temp);res.add(temp);last = current;isLeft = !isLeft;}return res;}}
[LeetCode] Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in each of the two partitions.
For example,
Given
return
Given
1->4->3->2->5->2 and x = 3,return
1->2->2->4->3->5.
解题思路一:
弄两个dummyhead,原list从左向右扫描,小于x的加在第一个之后,大于等于加到第二个之后,最后合并两个list。
解题思路二:
两个指针,左指针开始指向dummyhead,右指针指向head,如果右指针所指处小于x,两指针同时往右移动,直到右指针指向第一个大于等于x的node,接下来每当右指针的下一个小于x,就把那个node插到左指针之后,右指针则向前跳一步。
public ListNode partition(ListNode head, int x) { ListNode dummyhead = new ListNode(0); ListNode left = new ListNode(0); ListNode right = new ListNode(0); ListNode temp = new ListNode(0); ListNode firstright = new ListNode(0); dummyhead.next = head; left = dummyhead; right = head; if(right == null) return null; while(right.val<x) { right = right.next; left = left.next; if(right == null) return head; } firstright = right; //记录第一个大于等于x的node,后面交换位置时需要。 while(right.next!=null) { if(right.next.val>=x) right = right.next; else { temp = right.next.next; left.next = right.next; right.next = temp; left = left.next; left.next = firstright; } } return dummyhead.next; } }
2014年3月21日星期五
经常碰到的bug
Java里 ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer>> solution = new ArrayList<Integer>>();
result.add(solution); 小心这里,solution是原版object, 如果后面被改动了,result也就跟着变了。
这里和C++里常用的Vector<Vector<int>> result的情况不一样,因为c++里 vector::push_back()是Value to be copied (or moved) to the new element. 复制了,不是原版!
res.push_back(solution);
所以Java里碰到类似情况,最好新建一个拷贝,然后加入result.
ArrayList<Integer>> solution = new ArrayList<Integer>>();
result.add(solution); 小心这里,solution是原版object, 如果后面被改动了,result也就跟着变了。
这里和C++里常用的Vector<Vector<int>> result的情况不一样,因为c++里 vector::push_back()是Value to be copied (or moved) to the new element. 复制了,不是原版!
res.push_back(solution);
所以Java里碰到类似情况,最好新建一个拷贝,然后加入result.
Dynamic Programming
什么是动态规划(DP)?
http://blog.csdn.net/buaa_shang/article/details/11771159
非常重要!,不要认为概念不重要,理解的深刻,你才知道对于什么样的问题去考虑有没有动态规划的方法,以及如何去使用动态规划。
1)动态规划是运筹学中用于求解决策过程中的最优化数学方法。 当然,我们在这里关注的是作为一种算法设计技术,作为一种使用多阶段决策过程最优的通用方法。
它是应用数学中用于解决某类最优化问题的重要工具。
2)如果问题是由交叠的子问题所构成,我们就可以用动态规划技术来解决它,一般来说,这样的子问题出现在对给定问题求解的递推关系中,这个递推关系包含了相
同问题的更小子问题的解。动态规划法建议,与其对交叠子问题一次又一次的求解,不如把每个较小子问题只求解一次并把结果记录在表中(动态规划也是空间换时间
的),这样就可以从表中得到原始问题的解。
关键词:
它往往是解决最优化问题滴
问题可以表现为多阶段决策(去网上查查什么是多阶段决策!)
交叠子问题:什么是交叠子问题,最有子结构性质。
动态规划的思想是什么:记忆,空间换时间,不重复求解,由交叠子问题从较小问题解逐步决策,构造较大问题的解。
http://blog.csdn.net/buaa_shang/article/details/11771159
非常重要!,不要认为概念不重要,理解的深刻,你才知道对于什么样的问题去考虑有没有动态规划的方法,以及如何去使用动态规划。
1)动态规划是运筹学中用于求解决策过程中的最优化数学方法。 当然,我们在这里关注的是作为一种算法设计技术,作为一种使用多阶段决策过程最优的通用方法。
它是应用数学中用于解决某类最优化问题的重要工具。
2)如果问题是由交叠的子问题所构成,我们就可以用动态规划技术来解决它,一般来说,这样的子问题出现在对给定问题求解的递推关系中,这个递推关系包含了相
同问题的更小子问题的解。动态规划法建议,与其对交叠子问题一次又一次的求解,不如把每个较小子问题只求解一次并把结果记录在表中(动态规划也是空间换时间
的),这样就可以从表中得到原始问题的解。
关键词:
它往往是解决最优化问题滴
问题可以表现为多阶段决策(去网上查查什么是多阶段决策!)
交叠子问题:什么是交叠子问题,最有子结构性质。
动态规划的思想是什么:记忆,空间换时间,不重复求解,由交叠子问题从较小问题解逐步决策,构造较大问题的解。
Dynamic Programming, Divide and Conquer
DOC一般适合用递归,而DP不适合。
下面一段话来自: http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf
Why did recursion work so well with divide-and-conquer? The key point is that in doc, a problem is expressed in terms of subproblems that are substantially smaller, say half the size. Because of this sharp drop in problem size, the full recursion tree has only logarithmic depth and a polynomial number of nodes.
In contrast, in a typical dynamic programming formulation, a problem is reduced to subproblems that are only slightly smaller. Thus the full recursion tree generally has polynomial depth and an exponential number of nodes. However, it turns out that most of these nodes are repeats, that there are not too many distinct subproblems among them, Efficiency is therefore obtained by explicitly enumerating the distinct subproblems and solving them in the right order.
下面一段话来自: http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf
Why did recursion work so well with divide-and-conquer? The key point is that in doc, a problem is expressed in terms of subproblems that are substantially smaller, say half the size. Because of this sharp drop in problem size, the full recursion tree has only logarithmic depth and a polynomial number of nodes.
In contrast, in a typical dynamic programming formulation, a problem is reduced to subproblems that are only slightly smaller. Thus the full recursion tree generally has polynomial depth and an exponential number of nodes. However, it turns out that most of these nodes are repeats, that there are not too many distinct subproblems among them, Efficiency is therefore obtained by explicitly enumerating the distinct subproblems and solving them in the right order.
2014年3月19日星期三
Database normalization
Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database using the defined relationships. http://en.wikipedia.org/wiki/Database_normalization
Sounds awesome right? Can be, not always. There are pros and cons to it. Sometimes a denormalization structure is best. I don't think anyone will agree that normalization is the answer 100%. While there are more points to the below, I'll only cover a few basic ones.
Normalization
Pros:
Pros:
The ultimate answer is to know both normalized and denormalized DB strategies. Through thorough planning of a solution, you can determine the best approach. As for asking about database normalization, I think the best initial questions to ask up front are:
a) are the developers of the solution competent
b) did they take normalization into account when designing the solution
For more information, I strongly encourage you to do some more research into these concepts. It can only help!
http://daxdude.blogspot.com/2013/10/what-is-database-normalization-goodbad.html#!/2013/10/what-is-database-normalization-goodbad.html
Sounds awesome right? Can be, not always. There are pros and cons to it. Sometimes a denormalization structure is best. I don't think anyone will agree that normalization is the answer 100%. While there are more points to the below, I'll only cover a few basic ones.
Normalization
Pros:
- Updating tables can be faster (fewer fields)
- Can be less risk of database locking
- More flexibility to expand functionality of solution
- Removes or reduces redundancy
- Increase data retrieval times for single tasks (if designed correctly)
- Enforce relationships between data in joined tables (referential integrity)
- Can split up a table with many fields that will be quite large into multiple database servers
- Indexing strategies not as effective as data is spread out across multiple tables
- If a developer doesn't know what they are doing (or requirements are incorrectly identified), it can create a mess very quickly
Pros:
- don't have to worry about joins in a denormalized structure.
- reporting and integration can be an easier task than white boarding out a network of tables.
- Indexing can be more effective
- Easier to maintain and understand schema
- Good approach to consider when CPU is an issue
- Updating tables might be slower
- Updating development on one large table with many fields
- Retrieving records may be slower
The ultimate answer is to know both normalized and denormalized DB strategies. Through thorough planning of a solution, you can determine the best approach. As for asking about database normalization, I think the best initial questions to ask up front are:
a) are the developers of the solution competent
b) did they take normalization into account when designing the solution
For more information, I strongly encourage you to do some more research into these concepts. It can only help!
http://daxdude.blogspot.com/2013/10/what-is-database-normalization-goodbad.html#!/2013/10/what-is-database-normalization-goodbad.html
2014年3月18日星期二
如何理解 XPath、DOM、XHTML、XML、jQuery、JavaScript、CSS 之间的关系?
XML是一种存储数据的格式。
XPath是用来在XML中查找信息的语言。
DOM是处理XML的接口。
XHTML是符合XML规范的HTML。
CSS是用来修饰或改变HTML样式的语言。
JavaScript一般用于客户端的web脚本语言,包含了DOM。
JQuery是JavaScrpt的一种框架,用于简化JavaScript开发。
http://blog.csdn.net/cyr_hongfeng/article/details/8752854
XPath是用来在XML中查找信息的语言。
DOM是处理XML的接口。
XHTML是符合XML规范的HTML。
CSS是用来修饰或改变HTML样式的语言。
JavaScript一般用于客户端的web脚本语言,包含了DOM。
JQuery是JavaScrpt的一种框架,用于简化JavaScript开发。
http://blog.csdn.net/cyr_hongfeng/article/details/8752854
在网上浏览到这篇博客本来想自己总结但是发现人家写的已经想当好了,让我想精简也无法精简那就挑选我认为重点的东西赋值粘贴 过来
如果你是一个Web开发初学者,那么你难免会在网上搜索HTML, CSS, XML, JS(Javascript), DOM, XSL等等这些词的意思,然而,随着学习的深入。当你把他们搅在一起,你又糊涂了,你会不停的问,HTML是什么?CSS是什么?XML是什么?JS是什么?它们到底有什么用?无论是网络百科,还是一些IT专题网站,又或者一些牛人博客,他们都会告诉你,某个单一的东西是什么,这类文章很多,但很少有涉及,它们组合起来是什么,有什么用。我想,我写这篇文章,就是为了说明一下这个他们很少涉及的问题。
归纳、总结、提炼能力是我们进步的发动机,这种能力是可以有意识地培养的,拉卡拉电子支付公司董事长兼总裁孙陶然提到:在拉卡拉我们要求用三条说清楚任何问题就是一种能力训练,任何问题如果不能用三条说清楚说明你还没想透。
在这里,我争取用最根本的语言向大家分别说明HTML, CSS, XML, JS到底是什么,有什么用。然后我们再来看把他们组合起来是什么,有什么用。当然如果你对HTML, CSS, XML, JS有足够了解,可以直接跳过,看文章的后半部分,那里才是本文核心所在。
第一部分
1. HTML超文本标记语言 (Hyper Text Markup Language) ,是用来描述网页的一种标记语言。
<html>
<head>
<title>HTML</title>
</head>
<body>
<p id="num1">Hello World! I'm HTML</p>
</body>
</html>
网页文件本身是一种文本文件,通过在文本文件中添加标记,可以告诉浏览器如何显示其中的内容(如:文字如何处理,画面如何安排,图片如何显示等)。
HTML之所以称为超文本标记语言,是因为文本中包含了所谓“超链接”点。超文本(Hypertext)是用超链接的方法,将各种不同空间的文字信息组织在一起的网状文本。
概括,HTML就是整合网页结构和内容显示的一种语言。
Hello World! I'm HTML
浏览器按顺序阅读网页文件,然后根据标记符解释和显示其标记的内容。
这段内容在浏览器上显示的结果是:Hello World! I'm HTML
我们看<p>标签上有一个id,这是<p>这个标签的唯一标识,方便别人找到它,对它进行操作。
2. CSS 层叠样式表单(Cascading StyleSheet)。是将样式信息与网页内容分离的一种标记性语言 。作为网站开发者,你能够为每个HTML元素定义样式,并将之应用于你希望的任意多的页面中。如需进行全局的更新,只需简单地改变样式,然后网站中的所有元素均会自动地更新。这样,即设计人员能够将更多的时间用在设计方面,而不是费力克服HTML的限制。说白了,CSS就是设置网页上HTML元素属性的语言。
CSS代码:
#hello{
color:blue;
}
当把这段CSS代码应用于HTML中,它会找到id为“hello”的HTML标签,将其中的内容以蓝色显示出来;具体的插入HTML的方法这里不再赘述(说一句,只说明是什么,有什么用的问题,不关注技术细节,技术细节网上很好找)。
3. Javascript,首先说明JavaScript和Java无关,JavaScript 是属于网络的脚本语言!那么为什么名字如此相似?这是典型的市场营销方面的成功,它的推广成功,也是借了Java的东风。当微软开始意识到Javascript在Web开发人员中流行起来时,微软还是一贯风格,建立了自己的脚本语言,JScript。
Javascript是一种基于对象(Object)和事件驱动(Event Driven)并具有安全性能的脚本语言。使用它的目的是与HTML超文本标记语言、Java脚本语言(Java小程序)一起实现在一个Web页面中链接多个对象,与Web客户交互作用。例如可以设置鼠标悬停效果,在客户端验证表单,创建定制的HTML页面,显示警告框,设置cookie等等。
网页中所有的对数据进行判断、操作以及向浏览者反馈信息的本地代码实现部分均是Javascript(当然也有其他的),这样既可以使网页更具交互性,给用户提供更令人兴奋的体验,同时减轻了服务器负担。
JS的代码如下:
function jsHello(){
alert('Hello World!');
}
当把以上代码应用于HTML代码,它会在你的HTML载入时,弹出一个内容为“Hello World!”的对话框。同样,它是通过嵌入或调入在标准的HTML语言中实现的,至于如何嵌入或调入不再赘述,理由上面提到了。
4. Xml可扩展标记语言 (Extensible MarkupLanguage),是一套定义语义标记的规则,这些标记将文档分成许多部件并对这些部件加以标识。它也是元标记语言,即定义了用于定义其他与特定领域有关的、语义的、结构化的标记语言的句法语言。你可以把XML理解为一种数据库,例如rss就是xml的一种变体。
XML代码如下:
<Hello> <bcd>China</bcd> <bcd>USA</bcd> <bcd>UK</bcd> </Hello>
XML的起因是,用户受到SGML(后面再说)复杂性的挫伤和HTML的不充分。相对HTML来说,XML更追求严谨性,如果说你在HTML代码中标签比较混乱,如未关闭等,或许浏览器会忽略这些错误;但同样的事情发生在XML中会给你带来大麻烦。
铺垫终于完了,在进入正题之前,建议大家对比着图来理解后边的内容,废话不多说,开始进入正题。
第二部分
这里的DOM指的是HTML DOM。HTML DOM是W3C的标准,同时它也是HTML的文档对象模型的缩写(the Document Object Model for HTML)。HTML DOM定义了用于HTML的一系列标准的对象,以及访问和处理HTML文档的标准方法。通过DOM,可以访问所有的HTML元素,连同它们所包含的文本和属性。其中的内容可以修改和删除,同时也可以创建新的元素。HTML DOM独立于平台和编程语言。它可被任何编程语言诸如Java、Javascript和VBScript所使用。HTML DOM就是HTML语言对外界开通的接口,以便其他语言能够访问或修改HTML内部的元素。
当js需要对html元素进行操作时,DOM是一个很必要的对象。
你便可以通过利用DOM对象构造如下代码并插入到HTML代码中的任何位置来实现。
<script> window.onload=function hello(){ document.getElementById("hello").innerHTML="Hello China!"; } </script>
当用CSS去修饰HTML中的元素,这一过程可以称为声明HTML元素样式的过程。
SGML标准通用标记语言(standardgeneralized markup language)。由于SGML的复杂,导致难以普及。SGML有非常强大的适应性,也正是因为同样的原因,导致在小型的应用中难以普及。HTML 和 XML同样衍生于SGML:XML可以被认为是SGML的一个子集,而HTML是SGML的一个应用。XML的产生就是为了简化SGML,以便用于更加通用的目的。比如语义Web,它已经应用于大量的场合,比较著名的有XHTML、RSS 、XML-RPC 和SOAP 。
XHTML是可扩展超文本标识语言(TheExtensible HyperText MarkupLanguage)。HTML是一种基本的Web网页设计语言,XHTML是一个基于XML的置标语言,看起来与HTML有些相象,只有一些小的但重要的区别,XHTML就是一个扮演着类似HTML的角色的XML,所以,本质上说,XHTML是一个过渡技术,结合了部分XML的强大功能及大多数HTML的简单特性。
简单的说,XHTML比HTML要严谨些,但又没像XML那么严重——譬如所有的XHTML标签以及属性必须要小写,属性性必须要加双引号(当然如今的浏览器不管是IE还是FF,对HTML和XHTML采取兼容措施,这也是XSS产生的根本原因),而且也可以像XML一样自定义部分标签,因此有了极大的灵活性。
看到这里我如突然发现一个web开发很重要的问题xss漏洞这里我并不对此问题进行分析,将在下以后的笔记中笔记中着重记录研究xss漏洞
而且进入了XHTML时代,大家倡导的是CSS+DIV,这也是web2.0的基础。
DHTML只是一种制作网页的概念,实际上没有一个组织或机构推出过所谓的DHTML标准或技术规范之类的。DHTML不是一种技术、标准或规范,DHTML只是一种将目前已有的网页技术、语言标准整和运用,制作出能在下载后仍然能实时变换页面元素效果的网页的设计概念。DHTML就是动态的html,Dynamic HTML。传统的html页面是静态的,Dhtml就是在html页面上加入了javascript脚本,使其能根据用户的动作作出一定的响应,如鼠标移动到图片上,图片改变颜色,移动到导航栏,弹出一个动态菜单等等。
一般如:<img src="pic" onmouseover="it is a picture !">
Expression是微软为了使样式表能够在修饰HTML样式的同时执行javascript脚本而在IE浏览器中增加的一个功能,这样你可以做譬如:图片的自适应宽度,表格的隔行换色等等。
如:img{max-width:500px;width:expression(document.body.clientWidth> 200 ? "200px": "auto");}
XMLHTTP最通用的定义为:XmlHttp是一套可以在Javascript、VbScript、Jscript等脚本语言中通过http协议传送或从接收XML及其他数据的一套API。XmlHttp最大的用处是可以更新网页的部分内容而不需要刷新整个页面。
来自MSDN的解释:XmlHttp提供客户端同http服务器通讯的协议。客户端可以通过XmlHttp对象向http服务器发送请求并使用微软XML文档对象模型Microsoft® XML Document Object Model (DOM)处理回应。
现在的绝对多数浏览器都增加了对XmlHttp的支持,IE中使用ActiveXObject方式创建XmlHttp对象,其他浏览器如:Firefox、Opera等通过window.XMLHttpRequest来创建XmlHttp对象。
一个简单的定义IE的XmlHttp的对象及应用的实例如下:
var XmlHttp=new ActiveXObject("Microsoft.XMLhttp");
XmlHttp.Open("get","url",true);
XmlHttp.send(null);
XmlHttp.onreadystatechange=function ServerProcess(){
if (XmlHttp.readystate==4 || XmlHttp.readystate=='complete')
{
alert(XmlHttp.responseText);
}
}
XSLT(eXtensibleStylesheet LanguageTransformation)最早设计XSLT的用意是帮助XML文档(document)转换为其它文档。但是随着发展,XSLT已不仅仅用于将XML转换为HTML或其它文本格式,更全面的定义应该是:XSLT是一种用来转换XML文档结构的语言。
XSL-FO:XSL在转换XML文档时分为明显的两个过程,第一转换文档结构;其次将文档格式化输出。这两步可以分离开来并单独处理,因此XSL在发展过程中逐渐分裂为XSLT(结构转换)和XSL-FO(formattingobjects)(格式化输出)两种分支语言,其中XSL-FO的作用就类似CSS在HTML中的作用。
AJAX:异步JavaScript和XML(AsynchronousJavaScript and XML)。
最后一个东东,它算得上是web2.0思想的心。AJAX=CSS+HTML+JS+XML+DOM+XSLT+XMLHTTP。是指一种创建交互式网页应用的网页开发技术。AJAX不是一种单一的新技术,而是有机地利用了一系列相关的技术。
在 2005年,Google 通过其 Google Suggest 使 AJAX 变得流行起来。
Google Suggest 使用 AJAX 创造出动态性极强的 web 界面:当您在谷歌的搜索框输入关键字时,Javascript会把这些字符发送到服务器,然后服务器会返回一个搜索建议的列表。
在AJAX中,XmlHttp用来在不改变页面的情况下传输数据,其中传输的数据即是XML,然后通过XSLT将其格式化,利用js通过dom对象将其显示到HTML中,同时利用CSS确定数据的显示及位置。
这项技术在网络上的应用无处不在,如你的微博,你的邮箱,你的QQ空间,再如搜索引擎,电子商务平台,网络地图等等。
总结
终于完了,本文主要探讨了Web开发技术之间的关系,以及他们组合起来到底有什么用的问题。这篇文章总结得挺不容易的,期间参考了不少别人的东西,包括:W3CSchool在线教程,《BeginningXML With DOM and Ajax》,《Javascript基础教程》,《CSS 2.0中文手册》,还有一些大牛的博客,这里就不一一罗列了。希望对挣扎在Web开发学习前线的朋友有所帮助。如果有什么不够准确的地方,请大家斧正。
Schema
Schemas are generally stored in a data dictionary. Although a schema is defined in text database language, the term is often used to refer to a graphical depiction of the database structure. In other words, schema is the structure of the database that defines the objects in the database.
http://bhxkb2009.diandian.com/post/2012-04-01/18522093
数据库对象。首先,数据库对象是比较容易懂的。所有的表,视图,存储过程,触发器都称为数据库对象。
我们可以拿一个网站来做类比。一个网站包含很多的网页,图片,脚本文件,我们姑且称它为网站对象。
显然,我们不可能把所有的网站对象都放到一个文件夹下面,同样道理,数据库对象也不可能象煮饺子一样就在数据库里这么一锅出。对于网站,我们通常会把不同模块的文件放在不同的子文件夹下,那么谁是存放数据库对象的文件夹呢?答案就是:架构(Schema).
架构(Schema)。微软的官方说明(MSDN): "数据库架构是一个独立于数据库用户的非重复命名空间,您可以将架构视为对象的容器",详细参考http://technet.microsoft.com/zh-cn/library/ms190387.aspx.我们知道,在JAVA中,命名空间名其实就是文件夹名。因此我们非常明确一点:一个对象只能属于一个架构,就像一个文件只能存放于一个文件夹中一样。与文件夹不同的是,架构是不能嵌套的,如此而已。因此,我们要访问一个数据库对象的时候,通常应该是引用它的全名"架构名. 对象名",这点非常类似C#。
2014年3月15日星期六
2014年3月6日星期四
Binary Search Tree Tranversal
Depth-first[edit]
See also: Depth-first search
There are three types of depth-first traversal: pre-order,[1] in-order,[1] and post-order.[1] For a binary tree, they are defined as operations recursively at each node, starting with the root node as follows:Pre-order[edit]
- Visit the root.
- Traverse the left subtree.
- Traverse the right subtree.
In-order (symmetric)[edit]
- Traverse the left subtree.
- Visit root.
- Traverse the right subtree.
Post-order[edit]
- Traverse the left subtree.
- Traverse the right subtree.
- Visit the root.
Breadth-first[edit]
See also: Breadth-first search
Trees can also be traversed in level-order, where we visit every node on a level before going to a lower level.
订阅:
评论 (Atom)