<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Algorithms Q&amp;A - Recent questions and answers in Backtracking/DFS/BFS</title>
<link>https://notexponential.com/qa/graph-traversal</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: Topological Sort</title>
<link>https://notexponential.com/377/topological-sort?show=402#a402</link>
<description>1. DFS the graph: as each vertex is finished, insert it in a linked list.&lt;br /&gt;
&lt;br /&gt;
2. Return the linked list of vertices.&lt;br /&gt;
&lt;br /&gt;
Total cost: O(|V| + E).</description>
<category>Backtracking/DFS/BFS</category>
<guid isPermaLink="true">https://notexponential.com/377/topological-sort?show=402#a402</guid>
<pubDate>Mon, 05 Dec 2016 21:29:08 +0000</pubDate>
</item>
<item>
<title>Answered: Finding non-leaf node of a tree with no large subtrees</title>
<link>https://notexponential.com/376/finding-non-leaf-node-of-a-tree-with-no-large-subtrees?show=401#a401</link>
<description>&lt;p&gt;1. Recursively calculate the number of&amp;nbsp;node in sub-tree with each node. //O(n)&lt;/p&gt;&lt;p&gt;2. DFS&amp;nbsp;the tree;&amp;nbsp;for each node &lt;em&gt;i&lt;/em&gt;, father&amp;nbsp;of the node&amp;nbsp;&lt;em&gt;f&lt;/em&gt;,&amp;nbsp;and its children &lt;em&gt;c&lt;sub&gt;k&lt;/sub&gt;&lt;/em&gt;, if node_cnt[c&lt;sub&gt;k&lt;/sub&gt;] &amp;lt;= n/2&amp;nbsp;and node_cnt[&lt;em&gt;f&lt;/em&gt;] - node_cnt[&lt;em&gt;i&lt;/em&gt;] &amp;nbsp;&amp;lt;= n/2, the node is answer. //O(n)&lt;/p&gt;&lt;p&gt;The total cost is O(n).&lt;/p&gt;</description>
<category>Backtracking/DFS/BFS</category>
<guid isPermaLink="true">https://notexponential.com/376/finding-non-leaf-node-of-a-tree-with-no-large-subtrees?show=401#a401</guid>
<pubDate>Mon, 05 Dec 2016 21:13:14 +0000</pubDate>
</item>
</channel>
</rss>