mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-24 13:53:35 +08:00
Documentation for c26eea874d
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="generator" content="Doxygen 1.13.2"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: others/iterative_tree_traversals.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
@@ -60,7 +60,7 @@ window.MathJax = {
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<!-- Generated by Doxygen 1.13.2 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -221,18 +221,18 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
<p class="definition">Definition at line <a class="el" href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00183">183</a> of file <a class="el" href="../../d8/d90/iterative__tree__traversals_8cpp_source.html">iterative_tree_traversals.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 183</span> {</div>
|
||||
<div class="line"><span class="lineno"> 184</span> <span class="keywordflow">if</span> (root) {</div>
|
||||
<div class="line"><span class="lineno"> 185</span> std::stack<Node *> <a class="code hl_variable" href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a>;</div>
|
||||
<div class="line"><span class="lineno"> 185</span> std::stack<Node *> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>;</div>
|
||||
<div class="line"><span class="lineno"> 186</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">push</a>(root);</div>
|
||||
<div class="line"><span class="lineno"> 187</span> </div>
|
||||
<div class="line"><span class="lineno"> 188</span> <span class="keywordflow">while</span> (!<a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.empty()) {</div>
|
||||
<div class="line"><span class="lineno"> 189</span> <span class="keyword">const</span> <a class="code hl_class" href="../../db/d8b/struct_node.html">Node</a> *current = <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">top</a>();</div>
|
||||
<div class="line"><span class="lineno"> 189</span> <span class="keyword">const</span> <a class="code hl_struct" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html">Node</a> *current = <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">top</a>();</div>
|
||||
<div class="line"><span class="lineno"> 190</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0">pop</a>();</div>
|
||||
<div class="line"><span class="lineno"> 191</span> </div>
|
||||
<div class="line"><span class="lineno"> 192</span> <span class="keywordflow">if</span> (current->right) {</div>
|
||||
<div class="line"><span class="lineno"> 193</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">push</a>(current->right);</div>
|
||||
<div class="line"><span class="lineno"> 192</span> <span class="keywordflow">if</span> (current-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#af19e39acfc18b823be9d4879a20e1143">right</a>) {</div>
|
||||
<div class="line"><span class="lineno"> 193</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">push</a>(current-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#af19e39acfc18b823be9d4879a20e1143">right</a>);</div>
|
||||
<div class="line"><span class="lineno"> 194</span> }</div>
|
||||
<div class="line"><span class="lineno"> 195</span> <span class="keywordflow">if</span> (current->left) {</div>
|
||||
<div class="line"><span class="lineno"> 196</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">push</a>(current->left);</div>
|
||||
<div class="line"><span class="lineno"> 195</span> <span class="keywordflow">if</span> (current-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a>) {</div>
|
||||
<div class="line"><span class="lineno"> 196</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">push</a>(current-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a>);</div>
|
||||
<div class="line"><span class="lineno"> 197</span> }</div>
|
||||
<div class="line"><span class="lineno"> 198</span> <span class="keyword">delete</span> current;</div>
|
||||
<div class="line"><span class="lineno"> 199</span> }</div>
|
||||
@@ -242,8 +242,9 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
<div class="ttc" id="aclassstack_html_a3647fb4418890f19e0dc414b8092b8b0"><div class="ttname"><a href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0">stack::pop</a></div><div class="ttdeci">void pop()</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00062">stack.hpp:62</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_a90df277532c23519aa7ac3c08ed90a1d"><div class="ttname"><a href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">stack::push</a></div><div class="ttdeci">void push(const value_type &item)</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00047">stack.hpp:47</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_ae09630c4384903d187801921b2ddc709"><div class="ttname"><a href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">stack::top</a></div><div class="ttdeci">value_type top() const</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00056">stack.hpp:56</a></div></div>
|
||||
<div class="ttc" id="aparanthesis__matching_8cpp_html_aa37d24a036d239b3b528f13b9de880c7"><div class="ttname"><a href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a></div><div class="ttdeci">char stack[MAX]</div><div class="ttdef"><b>Definition</b> <a href="../../dc/dc5/paranthesis__matching_8cpp_source.html#l00020">paranthesis_matching.cpp:20</a></div></div>
|
||||
<div class="ttc" id="astruct_node_html"><div class="ttname"><a href="../../db/d8b/struct_node.html">Node</a></div><div class="ttdef"><b>Definition</b> <a href="../../d3/dce/linkedlist__implentation__usingarray_8cpp_source.html#l00014">linkedlist_implentation_usingarray.cpp:14</a></div></div>
|
||||
<div class="ttc" id="astructothers_1_1iterative__tree__traversals_1_1_node_html"><div class="ttname"><a href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html">others::iterative_tree_traversals::Node</a></div><div class="ttdoc">defines the structure of a node of the tree</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00058">iterative_tree_traversals.cpp:58</a></div></div>
|
||||
<div class="ttc" id="astructothers_1_1iterative__tree__traversals_1_1_node_html_a1dbaeff928e469a05251879568515b8e"><div class="ttname"><a href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">others::iterative_tree_traversals::Node::left</a></div><div class="ttdeci">struct Node * left</div><div class="ttdoc">struct pointer to left subtree.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00060">iterative_tree_traversals.cpp:60</a></div></div>
|
||||
<div class="ttc" id="astructothers_1_1iterative__tree__traversals_1_1_node_html_af19e39acfc18b823be9d4879a20e1143"><div class="ttname"><a href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#af19e39acfc18b823be9d4879a20e1143">others::iterative_tree_traversals::Node::right</a></div><div class="ttdeci">struct Node * right</div><div class="ttdoc">struct pointer to right subtree.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00061">iterative_tree_traversals.cpp:61</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -280,10 +281,10 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
<div class="line"><span class="lineno"> 382</span> <a class="code hl_class" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html">others::iterative_tree_traversals::BinaryTree</a></div>
|
||||
<div class="line"><span class="lineno"> 383</span> binaryTree; </div>
|
||||
<div class="line"><span class="lineno"> 385</span> <a class="code hl_struct" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html">others::iterative_tree_traversals::Node</a> *root = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(1);</div>
|
||||
<div class="line"><span class="lineno"> 386</span> root->left = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(2);</div>
|
||||
<div class="line"><span class="lineno"> 387</span> root->right = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(3);</div>
|
||||
<div class="line"><span class="lineno"> 388</span> root->left->left = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(4);</div>
|
||||
<div class="line"><span class="lineno"> 389</span> root->left->right = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(5);</div>
|
||||
<div class="line"><span class="lineno"> 386</span> root-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a> = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(2);</div>
|
||||
<div class="line"><span class="lineno"> 387</span> root-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#af19e39acfc18b823be9d4879a20e1143">right</a> = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(3);</div>
|
||||
<div class="line"><span class="lineno"> 388</span> root-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a>-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a> = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(4);</div>
|
||||
<div class="line"><span class="lineno"> 389</span> root-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#a1dbaeff928e469a05251879568515b8e">left</a>-><a class="code hl_variable" href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html#af19e39acfc18b823be9d4879a20e1143">right</a> = binaryTree.<a class="code hl_function" href="../../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a3078a5ccf45d6a7031dcf46e43de65b6">createNewNode</a>(5);</div>
|
||||
<div class="line"><span class="lineno"> 390</span> </div>
|
||||
<div class="line"><span class="lineno"> 391</span> std::cout << <span class="stringliteral">"\n| Tests for positive data value |"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 392</span> <a class="code hl_function" href="../../d3/dae/dsu__path__compression_8cpp.html#ae7880ce913f3058a35ff106d5be9e243">test1</a>(binaryTree, root); <span class="comment">// run preorder-iterative test</span></div>
|
||||
@@ -324,7 +325,6 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
<div class="ttc" id="aiterative__tree__traversals_8cpp_html_a038b236fe900f7bb7e57164f5bed66c2"><div class="ttname"><a href="#a038b236fe900f7bb7e57164f5bed66c2">test4</a></div><div class="ttdeci">static void test4(others::iterative_tree_traversals::BinaryTree binaryTree, others::iterative_tree_traversals::Node *root)</div><div class="ttdoc">Test the computed preorder with the actual preorder on negative value.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00291">iterative_tree_traversals.cpp:291</a></div></div>
|
||||
<div class="ttc" id="aiterative__tree__traversals_8cpp_html_aa9ef334cd7eb607f4eb8732566ea00b8"><div class="ttname"><a href="#aa9ef334cd7eb607f4eb8732566ea00b8">test5</a></div><div class="ttdeci">static void test5(others::iterative_tree_traversals::BinaryTree binaryTree, others::iterative_tree_traversals::Node *root)</div><div class="ttdoc">Test the computed postorder with the actual postorder on negative value.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00319">iterative_tree_traversals.cpp:319</a></div></div>
|
||||
<div class="ttc" id="aiterative__tree__traversals_8cpp_html_af727f920064f2b8f484b589b60d49b89"><div class="ttname"><a href="#af727f920064f2b8f484b589b60d49b89">test6</a></div><div class="ttdeci">static void test6(others::iterative_tree_traversals::BinaryTree binaryTree, others::iterative_tree_traversals::Node *root)</div><div class="ttdoc">Test the computed inorder with the actual inorder on negative value.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00346">iterative_tree_traversals.cpp:346</a></div></div>
|
||||
<div class="ttc" id="astructothers_1_1iterative__tree__traversals_1_1_node_html"><div class="ttname"><a href="../../d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html">others::iterative_tree_traversals::Node</a></div><div class="ttdoc">defines the structure of a node of the tree</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d90/iterative__tree__traversals_8cpp_source.html#l00058">iterative_tree_traversals.cpp:58</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -350,7 +350,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -413,7 +413,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -475,7 +475,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -537,7 +537,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -598,7 +598,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -659,7 +659,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -704,7 +704,7 @@ Iterative Inorder Traversal of a tree</h3>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_9510827d0b234b3cc54b29892f217477.html">others</a></li><li class="navelem"><a class="el" href="../../d8/d90/iterative__tree__traversals_8cpp.html">iterative_tree_traversals.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user