Ying's Hunting Journal
Saturday, January 30, 2016
Wednesday, January 27, 2016
Web
OSI, TCP/IP
These three pages are so far the best to simply understand OSI, TCP/IP.
http://www.hardwaresecrets.com/the-osi-reference-model-for-network-protocols/
http://www.hardwaresecrets.com/how-tcp-ip-protocol-works-part-1/
http://www.hardwaresecrets.com/how-tcp-ip-protocol-works-part-2/
These three pages are so far the best to simply understand OSI, TCP/IP.
http://www.hardwaresecrets.com/the-osi-reference-model-for-network-protocols/
http://www.hardwaresecrets.com/how-tcp-ip-protocol-works-part-1/
http://www.hardwaresecrets.com/how-tcp-ip-protocol-works-part-2/
What really happens when you navigate to a URL
HTML tutorial
Sunday, May 3, 2015
Friday, April 24, 2015
Pay Attention!!
Graph
directed graph or undirected graph?
The methods of graph traversal?
http://articles.leetcode.com/2012/05/clone-graph-part-i.html
Number
always consider if the algorithm will over flow!!!!!!
if negative or zero number will impact the final result!!!!!!
http://articles.leetcode.com/2012/01/palindrome-number.html
String
'a' to 'z'? Digits? Upper case letter? Does it contain ASCII characters only? Or even unicode character sets?
http://articles.leetcode.com/2011/05/longest-substring-without-repeating-characters.html
Tree
duplications?
http://articles.leetcode.com/2011/04/construct-binary-tree-from-inorder-and-preorder-postorder-traversal.html
directed graph or undirected graph?
The methods of graph traversal?
http://articles.leetcode.com/2012/05/clone-graph-part-i.html
Number
always consider if the algorithm will over flow!!!!!!
if negative or zero number will impact the final result!!!!!!
http://articles.leetcode.com/2012/01/palindrome-number.html
String
'a' to 'z'? Digits? Upper case letter? Does it contain ASCII characters only? Or even unicode character sets?
http://articles.leetcode.com/2011/05/longest-substring-without-repeating-characters.html
Tree
duplications?
http://articles.leetcode.com/2011/04/construct-binary-tree-from-inorder-and-preorder-postorder-traversal.html
Monday, April 20, 2015
Longest Palindromic Substring
Longest Palindromic Substring
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.
--------------------- thinking -----------------------------
https://leetcode.com/discuss/32204/simple-c-solution-8ms-13-lines
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-i.html
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
http://www.felix021.com/blog/read.php?2040
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.
--------------------- thinking -----------------------------
https://leetcode.com/discuss/32204/simple-c-solution-8ms-13-lines
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-i.html
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
http://www.felix021.com/blog/read.php?2040
word ladder
Word Ladder
Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:- Only one letter can be changed at a time
- Each intermediate word must exist in the dictionary
For example,
Given:
start =
end =
dict =
start =
"hit"
end =
"cog"
dict =
["hot","dot","dog","lot","log"]
As one shortest transformation is
return its length
"hit" -> "hot" -> "dot" -> "dog" -> "cog"
,return its length
5
.
Note:
- Return 0 if there is no such transformation sequence.
- All words have the same length.
- All words contain only lowercase alphabetic characters.
--------------- thinking -----------------------
A lot of optimizations are discussed in this post!!!! And why my codes is memory limit exceed!!!
http://www.cnblogs.com/linyx/p/3706688.html
Tuesday, April 14, 2015
Detect Cycle in a Directed Graph
Detect Cycle in a Directed Graph
Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least one cycle, else return false. For example, the following graph contains three cycles 0->2->0, 0->1->2->0 and 3->3, so your function must return true.
Solution
Depth First Traversal can be used to detect cycle in a Graph. DFS for a connected graph produces a tree. There is a cycle in a graph only if there is a back edge present in the graph. A back edge is an edge that is from a node to itself (selfloop) or one of its ancestor in the tree produced by DFS. In the following graph, there are 3 back edges, marked with cross sign. We can observe that these 3 back edges indicate 3 cycles present in the graph.
For a disconnected graph, we get the DFS forrest as output. To detect cycle, we can check for cycle in individual trees by checking back edges.
Solution
Depth First Traversal can be used to detect cycle in a Graph. DFS for a connected graph produces a tree. There is a cycle in a graph only if there is a back edge present in the graph. A back edge is an edge that is from a node to itself (selfloop) or one of its ancestor in the tree produced by DFS. In the following graph, there are 3 back edges, marked with cross sign. We can observe that these 3 back edges indicate 3 cycles present in the graph.
For a disconnected graph, we get the DFS forrest as output. To detect cycle, we can check for cycle in individual trees by checking back edges.
----------------------- thinking ----------------------------------
Subscribe to:
Posts (Atom)
I'm quite sure that my code of using one stack for post-order traversal works. You can use the same example above to go through it. I made iterative in-order, pre-order and post-order traversal as similar as possible:
{
stack s;
const Node *itr = root;
if (!itr) {
while (!s.empty() &&
itr == s.top()->right) {
itr = s.top();
s.pop();
printf("%d ",itr->value);
}
itr = s.empty() ? NULL : s.top()->right;
}
else
{
s.push(itr);
itr = itr->left;
}
}
}
{
stack s;
const Node *itr = root;
if (!itr){
itr = s.top();
s.pop();
printf("%d ",itr->value);
itr = itr->right;
}
else{
s.push(itr);
itr = itr->left;
}
}
}
{
stack s;
const Node *itr = root;
if (!itr){
itr = s.top();
s.pop();
itr = itr->right;
}
else{
printf("%d ",itr->value);
s.push(itr);
itr = itr->left;
}
}
}