TheAlgorithms-C/df/d3c/threaded__binary__trees_8c.html
2022-09-08 00:17:03 +00:00

642 lines
53 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<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.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: data_structures/binary_trees/threaded_binary_trees.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Algorithms_in_C<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('df/d3c/threaded__binary__trees_8c.html','../../'); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">threaded_binary_trees.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>This file is a simple implementation of a Threaded Binary Tree.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for threaded_binary_trees.c:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/df1/threaded__binary__trees_8c__incl.svg" width="166" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d8b/struct_node.html">Node</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="../../db/d8b/struct_node.html" title="Node, the basic data structure of the tree.">Node</a>, the basic data structure of the tree. <a href="../../db/d8b/struct_node.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ad8ecdcce462dd8e170ae1f164935aaa6"><td class="memItemLeft" align="right" valign="top"><a id="ad8ecdcce462dd8e170ae1f164935aaa6" name="ad8ecdcce462dd8e170ae1f164935aaa6"></a>
typedef struct <a class="el" href="../../db/d8b/struct_node.html">Node</a>&#160;</td><td class="memItemRight" valign="bottom"><b>node</b></td></tr>
<tr class="memdesc:ad8ecdcce462dd8e170ae1f164935aaa6"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="../../db/d8b/struct_node.html" title="Node, the basic data structure of the tree.">Node</a>, the basic data structure of the tree. <br /></td></tr>
<tr class="separator:ad8ecdcce462dd8e170ae1f164935aaa6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a4802bca3f38251543b4aba6765e0390d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d5/da1/structnode.html">node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a4802bca3f38251543b4aba6765e0390d">create_node</a> (int <a class="el" href="../../df/dea/structdata.html">data</a>)</td></tr>
<tr class="memdesc:a4802bca3f38251543b4aba6765e0390d"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates a new node param[in] data value to be inserted <a href="../../df/d3c/threaded__binary__trees_8c.html#a4802bca3f38251543b4aba6765e0390d">More...</a><br /></td></tr>
<tr class="separator:a4802bca3f38251543b4aba6765e0390d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a823432888332fc9f0aa6072cff28c3bb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a823432888332fc9f0aa6072cff28c3bb">insert_bt</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> **root, int <a class="el" href="../../df/dea/structdata.html">data</a>)</td></tr>
<tr class="memdesc:a823432888332fc9f0aa6072cff28c3bb"><td class="mdescLeft">&#160;</td><td class="mdescRight">inserts a node into the tree param[in,out] root pointer to node pointer to the topmost node of the tree param[in] data value to be inserted into the tree <a href="../../df/d3c/threaded__binary__trees_8c.html#a823432888332fc9f0aa6072cff28c3bb">More...</a><br /></td></tr>
<tr class="separator:a823432888332fc9f0aa6072cff28c3bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a306d567466f22e1e927aaed97d8bb58c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a306d567466f22e1e927aaed97d8bb58c">search</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> *root, int ele)</td></tr>
<tr class="memdesc:a306d567466f22e1e927aaed97d8bb58c"><td class="mdescLeft">&#160;</td><td class="mdescRight">searches for the element <a href="../../df/d3c/threaded__binary__trees_8c.html#a306d567466f22e1e927aaed97d8bb58c">More...</a><br /></td></tr>
<tr class="separator:a306d567466f22e1e927aaed97d8bb58c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4c1e06b5f0876ec9c1bd6817f3b7eda7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">inorder_display</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> *curr)</td></tr>
<tr class="memdesc:a4c1e06b5f0876ec9c1bd6817f3b7eda7"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs inorder traversal param[in] curr node pointer to the topmost node of the tree <a href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">More...</a><br /></td></tr>
<tr class="separator:a4c1e06b5f0876ec9c1bd6817f3b7eda7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a82ae0ee13788be51ca4ba6cddb0719"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">postorder_display</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> *curr)</td></tr>
<tr class="memdesc:a5a82ae0ee13788be51ca4ba6cddb0719"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs postorder traversal param[in] curr node pointer to the topmost node of the tree <a href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">More...</a><br /></td></tr>
<tr class="separator:a5a82ae0ee13788be51ca4ba6cddb0719"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8169ba0dfd5b8183672e444d1434bf9c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">preorder_display</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> *curr)</td></tr>
<tr class="memdesc:a8169ba0dfd5b8183672e444d1434bf9c"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs preorder traversal param[in] curr node pointer to the topmost node of the tree <a href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">More...</a><br /></td></tr>
<tr class="separator:a8169ba0dfd5b8183672e444d1434bf9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a284d683f74b6c884e79ba00d3d1c3317"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#a284d683f74b6c884e79ba00d3d1c3317">delete_bt</a> (<a class="el" href="../../d5/da1/structnode.html">node</a> **root, int ele)</td></tr>
<tr class="memdesc:a284d683f74b6c884e79ba00d3d1c3317"><td class="mdescLeft">&#160;</td><td class="mdescRight">deletion of a node from the tree if the node isn't present in the tree, it takes no action. <a href="../../df/d3c/threaded__binary__trees_8c.html#a284d683f74b6c884e79ba00d3d1c3317">More...</a><br /></td></tr>
<tr class="separator:a284d683f74b6c884e79ba00d3d1c3317"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">main function <a href="../../df/d3c/threaded__binary__trees_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >This file is a simple implementation of a Threaded Binary Tree. </p>
<p >Threaded Binary Tree is a binary tree variant in which all left child pointers that are NULL (in Linked list representation) point to its in-order predecessor, and all right child pointers that are NULL (in Linked list representation) point to its in-order successor. It has the following functionalities:</p><ul>
<li>Insertion</li>
<li>Search</li>
<li>Deletion</li>
<li>Listing of node keys inorder,preorder,postorder</li>
</ul>
<p >-see <a class="el" href="../../da/d02/binary__search__tree_8c.html" title="A basic unbalanced binary search tree implementation in C.">binary_search_tree.c</a></p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/amitnayakblr" target="_blank">Amitha Nayak</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a4802bca3f38251543b4aba6765e0390d" name="a4802bca3f38251543b4aba6765e0390d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4802bca3f38251543b4aba6765e0390d">&#9670;&#160;</a></span>create_node()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="../../d5/da1/structnode.html">node</a> * create_node </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>data</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>creates a new node param[in] data value to be inserted </p>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the new node </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 39</span>{</div>
<div class="line"><span class="lineno"> 40</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *ptr = (<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *)<a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>));</div>
<div class="line"><span class="lineno"> 41</span> ptr-&gt;rlink = ptr-&gt;llink = NULL;</div>
<div class="line"><span class="lineno"> 42</span> ptr-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> = <a class="code hl_struct" href="../../df/dea/structdata.html">data</a>;</div>
<div class="line"><span class="lineno"> 43</span> <span class="keywordflow">return</span> ptr;</div>
<div class="line"><span class="lineno"> 44</span>}</div>
<div class="ttc" id="amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a></div><div class="ttdeci">#define malloc(bytes)</div><div class="ttdoc">This macro replace the standard malloc function with malloc_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:18</div></div>
<div class="ttc" id="astructdata_html"><div class="ttname"><a href="../../df/dea/structdata.html">data</a></div><div class="ttdef"><b>Definition:</b> prime_factoriziation.c:25</div></div>
<div class="ttc" id="astructnode_html"><div class="ttname"><a href="../../d5/da1/structnode.html">node</a></div><div class="ttdoc">Node, the basic data structure in the tree.</div><div class="ttdef"><b>Definition:</b> binary_search_tree.c:15</div></div>
<div class="ttc" id="astructnode_html_a2d890bb9f6af0ffd73fe79b21124c2a2"><div class="ttname"><a href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">node::data</a></div><div class="ttdeci">int data</div><div class="ttdoc">data of the node</div><div class="ttdef"><b>Definition:</b> binary_search_tree.c:18</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a284d683f74b6c884e79ba00d3d1c3317" name="a284d683f74b6c884e79ba00d3d1c3317"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a284d683f74b6c884e79ba00d3d1c3317">&#9670;&#160;</a></span>delete_bt()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void delete_bt </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> **&#160;</td>
<td class="paramname"><em>root</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>ele</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>deletion of a node from the tree if the node isn't present in the tree, it takes no action. </p>
<p >param[in,out] root pointer to node pointer to the topmost node of the tree param[in] ele value to be deleted from the tree </p>
<div class="fragment"><div class="line"><span class="lineno"> 174</span>{</div>
<div class="line"><span class="lineno"> 175</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *temp;</div>
<div class="line"><span class="lineno"> 176</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *prev;</div>
<div class="line"><span class="lineno"> 177</span> <span class="keywordflow">if</span> (*root == NULL)</div>
<div class="line"><span class="lineno"> 178</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 179</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 180</span> {</div>
<div class="line"><span class="lineno"> 181</span> temp = *root;</div>
<div class="line"><span class="lineno"> 182</span> prev = NULL;</div>
<div class="line"><span class="lineno"> 183</span> <span class="comment">// search</span></div>
<div class="line"><span class="lineno"> 184</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><span class="lineno"> 185</span> {</div>
<div class="line"><span class="lineno"> 186</span> <span class="keywordflow">if</span> (temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> == ele)</div>
<div class="line"><span class="lineno"> 187</span> {</div>
<div class="line"><span class="lineno"> 188</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 189</span> }</div>
<div class="line"><span class="lineno"> 190</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ele &gt; temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>)</div>
<div class="line"><span class="lineno"> 191</span> {</div>
<div class="line"><span class="lineno"> 192</span> prev = temp;</div>
<div class="line"><span class="lineno"> 193</span> temp = temp-&gt;rlink;</div>
<div class="line"><span class="lineno"> 194</span> }</div>
<div class="line"><span class="lineno"> 195</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 196</span> {</div>
<div class="line"><span class="lineno"> 197</span> prev = temp;</div>
<div class="line"><span class="lineno"> 198</span> temp = temp-&gt;llink;</div>
<div class="line"><span class="lineno"> 199</span> }</div>
<div class="line"><span class="lineno"> 200</span> }</div>
<div class="line"><span class="lineno"> 201</span> }</div>
<div class="line"><span class="lineno"> 202</span> </div>
<div class="line"><span class="lineno"> 203</span> <span class="keywordflow">if</span> (temp == NULL)</div>
<div class="line"><span class="lineno"> 204</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 205</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 206</span> {</div>
<div class="line"><span class="lineno"> 207</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *replacement; <span class="comment">// deleted node&#39;s replacement</span></div>
<div class="line"><span class="lineno"> 208</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *t;</div>
<div class="line"><span class="lineno"> 209</span> <span class="keywordflow">if</span> (temp-&gt;llink == NULL &amp;&amp; temp-&gt;rlink == NULL)</div>
<div class="line"><span class="lineno"> 210</span> {</div>
<div class="line"><span class="lineno"> 211</span> replacement = NULL;</div>
<div class="line"><span class="lineno"> 212</span> }</div>
<div class="line"><span class="lineno"> 213</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp-&gt;llink == NULL &amp;&amp; temp-&gt;rlink != NULL)</div>
<div class="line"><span class="lineno"> 214</span> {</div>
<div class="line"><span class="lineno"> 215</span> replacement = temp-&gt;rlink;</div>
<div class="line"><span class="lineno"> 216</span> }</div>
<div class="line"><span class="lineno"> 217</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp-&gt;llink != NULL &amp;&amp; temp-&gt;rlink == NULL)</div>
<div class="line"><span class="lineno"> 218</span> {</div>
<div class="line"><span class="lineno"> 219</span> replacement = temp-&gt;llink;</div>
<div class="line"><span class="lineno"> 220</span> }</div>
<div class="line"><span class="lineno"> 221</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 222</span> {</div>
<div class="line"><span class="lineno"> 223</span> replacement = temp-&gt;rlink; <span class="comment">// replaced with inorder successor</span></div>
<div class="line"><span class="lineno"> 224</span> t = replacement;</div>
<div class="line"><span class="lineno"> 225</span> <span class="keywordflow">while</span> (t-&gt;llink != NULL)</div>
<div class="line"><span class="lineno"> 226</span> {</div>
<div class="line"><span class="lineno"> 227</span> t = t-&gt;llink;</div>
<div class="line"><span class="lineno"> 228</span> }</div>
<div class="line"><span class="lineno"> 229</span> t-&gt;llink =</div>
<div class="line"><span class="lineno"> 230</span> temp-&gt;llink; <span class="comment">// leftmost node of the replacement is linked to</span></div>
<div class="line"><span class="lineno"> 231</span> <span class="comment">// the left child of the deleted node</span></div>
<div class="line"><span class="lineno"> 232</span> }</div>
<div class="line"><span class="lineno"> 233</span> </div>
<div class="line"><span class="lineno"> 234</span> <span class="keywordflow">if</span> (temp == *root)</div>
<div class="line"><span class="lineno"> 235</span> {</div>
<div class="line"><span class="lineno"> 236</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(*root);</div>
<div class="line"><span class="lineno"> 237</span> *root = replacement;</div>
<div class="line"><span class="lineno"> 238</span> }</div>
<div class="line"><span class="lineno"> 239</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (prev-&gt;llink == temp)</div>
<div class="line"><span class="lineno"> 240</span> {</div>
<div class="line"><span class="lineno"> 241</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(prev-&gt;llink);</div>
<div class="line"><span class="lineno"> 242</span> prev-&gt;llink = replacement;</div>
<div class="line"><span class="lineno"> 243</span> }</div>
<div class="line"><span class="lineno"> 244</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (prev-&gt;rlink == temp)</div>
<div class="line"><span class="lineno"> 245</span> {</div>
<div class="line"><span class="lineno"> 246</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(prev-&gt;rlink);</div>
<div class="line"><span class="lineno"> 247</span> prev-&gt;rlink = replacement;</div>
<div class="line"><span class="lineno"> 248</span> }</div>
<div class="line"><span class="lineno"> 249</span> }</div>
<div class="line"><span class="lineno"> 250</span>}</div>
<div class="ttc" id="amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a></div><div class="ttdeci">#define free(ptr)</div><div class="ttdoc">This macro replace the standard free function with free_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:26</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a4c1e06b5f0876ec9c1bd6817f3b7eda7" name="a4c1e06b5f0876ec9c1bd6817f3b7eda7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4c1e06b5f0876ec9c1bd6817f3b7eda7">&#9670;&#160;</a></span>inorder_display()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void inorder_display </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> *&#160;</td>
<td class="paramname"><em>curr</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>performs inorder traversal param[in] curr node pointer to the topmost node of the tree </p>
<div class="fragment"><div class="line"><span class="lineno"> 130</span>{</div>
<div class="line"><span class="lineno"> 131</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><span class="lineno"> 132</span> {</div>
<div class="line"><span class="lineno"> 133</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">inorder_display</a>(curr-&gt;llink);</div>
<div class="line"><span class="lineno"> 134</span> printf(<span class="stringliteral">&quot;%d\t&quot;</span>, curr-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>);</div>
<div class="line"><span class="lineno"> 135</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">inorder_display</a>(curr-&gt;rlink);</div>
<div class="line"><span class="lineno"> 136</span> }</div>
<div class="line"><span class="lineno"> 137</span>}</div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a4c1e06b5f0876ec9c1bd6817f3b7eda7"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">inorder_display</a></div><div class="ttdeci">void inorder_display(node *curr)</div><div class="ttdoc">performs inorder traversal param[in] curr node pointer to the topmost node of the tree</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:129</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/threaded__binary__trees_8c_a4c1e06b5f0876ec9c1bd6817f3b7eda7_cgraph.svg" width="120" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a823432888332fc9f0aa6072cff28c3bb" name="a823432888332fc9f0aa6072cff28c3bb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a823432888332fc9f0aa6072cff28c3bb">&#9670;&#160;</a></span>insert_bt()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void insert_bt </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> **&#160;</td>
<td class="paramname"><em>root</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>data</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>inserts a node into the tree param[in,out] root pointer to node pointer to the topmost node of the tree param[in] data value to be inserted into the tree </p>
<div class="fragment"><div class="line"><span class="lineno"> 52</span>{</div>
<div class="line"><span class="lineno"> 53</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *new_node = <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a4802bca3f38251543b4aba6765e0390d">create_node</a>(<a class="code hl_struct" href="../../df/dea/structdata.html">data</a>);</div>
<div class="line"><span class="lineno"> 54</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *temp; <span class="comment">// to be deleted</span></div>
<div class="line"><span class="lineno"> 55</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *prev; <span class="comment">// keeps track of the parent of the element deleted</span></div>
<div class="line"><span class="lineno"> 56</span> <span class="keywordflow">if</span> (*root == NULL)</div>
<div class="line"><span class="lineno"> 57</span> {</div>
<div class="line"><span class="lineno"> 58</span> *root = new_node;</div>
<div class="line"><span class="lineno"> 59</span> }</div>
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 61</span> {</div>
<div class="line"><span class="lineno"> 62</span> temp = *root;</div>
<div class="line"><span class="lineno"> 63</span> prev = NULL;</div>
<div class="line"><span class="lineno"> 64</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><span class="lineno"> 65</span> {</div>
<div class="line"><span class="lineno"> 66</span> <span class="keywordflow">if</span> (new_node-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> &gt; temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>)</div>
<div class="line"><span class="lineno"> 67</span> {</div>
<div class="line"><span class="lineno"> 68</span> prev = temp;</div>
<div class="line"><span class="lineno"> 69</span> temp = temp-&gt;rlink;</div>
<div class="line"><span class="lineno"> 70</span> }</div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (new_node-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> &lt; temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>)</div>
<div class="line"><span class="lineno"> 72</span> {</div>
<div class="line"><span class="lineno"> 73</span> prev = temp;</div>
<div class="line"><span class="lineno"> 74</span> temp = temp-&gt;llink;</div>
<div class="line"><span class="lineno"> 75</span> }</div>
<div class="line"><span class="lineno"> 76</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 77</span> {</div>
<div class="line"><span class="lineno"> 78</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 79</span> }</div>
<div class="line"><span class="lineno"> 80</span> }</div>
<div class="line"><span class="lineno"> 81</span> </div>
<div class="line"><span class="lineno"> 82</span> <span class="keywordflow">if</span> (new_node-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> &gt; prev-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>)</div>
<div class="line"><span class="lineno"> 83</span> {</div>
<div class="line"><span class="lineno"> 84</span> prev-&gt;rlink = new_node;</div>
<div class="line"><span class="lineno"> 85</span> }</div>
<div class="line"><span class="lineno"> 86</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 87</span> {</div>
<div class="line"><span class="lineno"> 88</span> prev-&gt;llink = new_node;</div>
<div class="line"><span class="lineno"> 89</span> }</div>
<div class="line"><span class="lineno"> 90</span> }</div>
<div class="line"><span class="lineno"> 91</span>}</div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a4802bca3f38251543b4aba6765e0390d"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a4802bca3f38251543b4aba6765e0390d">create_node</a></div><div class="ttdeci">node * create_node(int data)</div><div class="ttdoc">creates a new node param[in] data value to be inserted</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:38</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/threaded__binary__trees_8c_a823432888332fc9f0aa6072cff28c3bb_cgraph.svg" width="224" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&#160;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>main function </p>
<div class="fragment"><div class="line"><span class="lineno"> 256</span>{</div>
<div class="line"><span class="lineno"> 257</span> printf(<span class="stringliteral">&quot;BINARY THREADED TREE: \n&quot;</span>);</div>
<div class="line"><span class="lineno"> 258</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *root = NULL;</div>
<div class="line"><span class="lineno"> 259</span> <span class="keywordtype">int</span> choice, n;</div>
<div class="line"><span class="lineno"> 260</span> <span class="keywordflow">do</span></div>
<div class="line"><span class="lineno"> 261</span> {</div>
<div class="line"><span class="lineno"> 262</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;1. Insert into BT&quot;</span>);</div>
<div class="line"><span class="lineno"> 263</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;2. Print BT - inorder&quot;</span>);</div>
<div class="line"><span class="lineno"> 264</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;3. Print BT - preorder&quot;</span>);</div>
<div class="line"><span class="lineno"> 265</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;4. print BT - postorder&quot;</span>);</div>
<div class="line"><span class="lineno"> 266</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;5. delete from BT&quot;</span>);</div>
<div class="line"><span class="lineno"> 267</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;6. search in BT&quot;</span>);</div>
<div class="line"><span class="lineno"> 268</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Type 0 to exit&quot;</span>);</div>
<div class="line"><span class="lineno"> 269</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;choice);</div>
<div class="line"><span class="lineno"> 270</span> </div>
<div class="line"><span class="lineno"> 271</span> <span class="keywordflow">switch</span> (choice)</div>
<div class="line"><span class="lineno"> 272</span> {</div>
<div class="line"><span class="lineno"> 273</span> <span class="keywordflow">case</span> 1:</div>
<div class="line"><span class="lineno"> 274</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Enter a no:&quot;</span>);</div>
<div class="line"><span class="lineno"> 275</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><span class="lineno"> 276</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a823432888332fc9f0aa6072cff28c3bb">insert_bt</a>(&amp;root, n);</div>
<div class="line"><span class="lineno"> 277</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 278</span> <span class="keywordflow">case</span> 2:</div>
<div class="line"><span class="lineno"> 279</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a4c1e06b5f0876ec9c1bd6817f3b7eda7">inorder_display</a>(root);</div>
<div class="line"><span class="lineno"> 280</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><span class="lineno"> 281</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 282</span> <span class="keywordflow">case</span> 3:</div>
<div class="line"><span class="lineno"> 283</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">preorder_display</a>(root);</div>
<div class="line"><span class="lineno"> 284</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><span class="lineno"> 285</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 286</span> <span class="keywordflow">case</span> 4:</div>
<div class="line"><span class="lineno"> 287</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">postorder_display</a>(root);</div>
<div class="line"><span class="lineno"> 288</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><span class="lineno"> 289</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 290</span> <span class="keywordflow">case</span> 5:</div>
<div class="line"><span class="lineno"> 291</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Enter a no:&quot;</span>);</div>
<div class="line"><span class="lineno"> 292</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><span class="lineno"> 293</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a284d683f74b6c884e79ba00d3d1c3317">delete_bt</a>(&amp;root, n);</div>
<div class="line"><span class="lineno"> 294</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 295</span> <span class="keywordflow">case</span> 6:</div>
<div class="line"><span class="lineno"> 296</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Enter a no:&quot;</span>);</div>
<div class="line"><span class="lineno"> 297</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><span class="lineno"> 298</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a306d567466f22e1e927aaed97d8bb58c">search</a>(root, n);</div>
<div class="line"><span class="lineno"> 299</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 300</span> }</div>
<div class="line"><span class="lineno"> 301</span> } <span class="keywordflow">while</span> (choice != 0);</div>
<div class="line"><span class="lineno"> 302</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 303</span>}</div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a284d683f74b6c884e79ba00d3d1c3317"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a284d683f74b6c884e79ba00d3d1c3317">delete_bt</a></div><div class="ttdeci">void delete_bt(node **root, int ele)</div><div class="ttdoc">deletion of a node from the tree if the node isn't present in the tree, it takes no action.</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:173</div></div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a306d567466f22e1e927aaed97d8bb58c"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a306d567466f22e1e927aaed97d8bb58c">search</a></div><div class="ttdeci">void search(node *root, int ele)</div><div class="ttdoc">searches for the element</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:98</div></div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a5a82ae0ee13788be51ca4ba6cddb0719"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">postorder_display</a></div><div class="ttdeci">void postorder_display(node *curr)</div><div class="ttdoc">performs postorder traversal param[in] curr node pointer to the topmost node of the tree</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:143</div></div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a8169ba0dfd5b8183672e444d1434bf9c"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">preorder_display</a></div><div class="ttdeci">void preorder_display(node *curr)</div><div class="ttdoc">performs preorder traversal param[in] curr node pointer to the topmost node of the tree</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:157</div></div>
<div class="ttc" id="athreaded__binary__trees_8c_html_a823432888332fc9f0aa6072cff28c3bb"><div class="ttname"><a href="../../df/d3c/threaded__binary__trees_8c.html#a823432888332fc9f0aa6072cff28c3bb">insert_bt</a></div><div class="ttdeci">void insert_bt(node **root, int data)</div><div class="ttdoc">inserts a node into the tree param[in,out] root pointer to node pointer to the topmost node of the tr...</div><div class="ttdef"><b>Definition:</b> threaded_binary_trees.c:51</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/threaded__binary__trees_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="375" height="355"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a5a82ae0ee13788be51ca4ba6cddb0719" name="a5a82ae0ee13788be51ca4ba6cddb0719"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5a82ae0ee13788be51ca4ba6cddb0719">&#9670;&#160;</a></span>postorder_display()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void postorder_display </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> *&#160;</td>
<td class="paramname"><em>curr</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>performs postorder traversal param[in] curr node pointer to the topmost node of the tree </p>
<div class="fragment"><div class="line"><span class="lineno"> 144</span>{</div>
<div class="line"><span class="lineno"> 145</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><span class="lineno"> 146</span> {</div>
<div class="line"><span class="lineno"> 147</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">postorder_display</a>(curr-&gt;llink);</div>
<div class="line"><span class="lineno"> 148</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a5a82ae0ee13788be51ca4ba6cddb0719">postorder_display</a>(curr-&gt;rlink);</div>
<div class="line"><span class="lineno"> 149</span> printf(<span class="stringliteral">&quot;%d\t&quot;</span>, curr-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>);</div>
<div class="line"><span class="lineno"> 150</span> }</div>
<div class="line"><span class="lineno"> 151</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/threaded__binary__trees_8c_a5a82ae0ee13788be51ca4ba6cddb0719_cgraph.svg" width="135" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a8169ba0dfd5b8183672e444d1434bf9c" name="a8169ba0dfd5b8183672e444d1434bf9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8169ba0dfd5b8183672e444d1434bf9c">&#9670;&#160;</a></span>preorder_display()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void preorder_display </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> *&#160;</td>
<td class="paramname"><em>curr</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>performs preorder traversal param[in] curr node pointer to the topmost node of the tree </p>
<div class="fragment"><div class="line"><span class="lineno"> 158</span>{</div>
<div class="line"><span class="lineno"> 159</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><span class="lineno"> 160</span> {</div>
<div class="line"><span class="lineno"> 161</span> printf(<span class="stringliteral">&quot;%d\t&quot;</span>, curr-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>);</div>
<div class="line"><span class="lineno"> 162</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">preorder_display</a>(curr-&gt;llink);</div>
<div class="line"><span class="lineno"> 163</span> <a class="code hl_function" href="../../df/d3c/threaded__binary__trees_8c.html#a8169ba0dfd5b8183672e444d1434bf9c">preorder_display</a>(curr-&gt;rlink);</div>
<div class="line"><span class="lineno"> 164</span> }</div>
<div class="line"><span class="lineno"> 165</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/threaded__binary__trees_8c_a8169ba0dfd5b8183672e444d1434bf9c_cgraph.svg" width="128" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a306d567466f22e1e927aaed97d8bb58c" name="a306d567466f22e1e927aaed97d8bb58c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a306d567466f22e1e927aaed97d8bb58c">&#9670;&#160;</a></span>search()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void search </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d5/da1/structnode.html">node</a> *&#160;</td>
<td class="paramname"><em>root</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>ele</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>searches for the element </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">root</td><td>node pointer to the topmost node of the tree </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">ele</td><td>value searched for </td></tr>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 99</span>{</div>
<div class="line"><span class="lineno"> 100</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *temp = root;</div>
<div class="line"><span class="lineno"> 101</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><span class="lineno"> 102</span> {</div>
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">if</span> (temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a> == ele)</div>
<div class="line"><span class="lineno"> 104</span> {</div>
<div class="line"><span class="lineno"> 105</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 106</span> }</div>
<div class="line"><span class="lineno"> 107</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ele &gt; temp-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2">data</a>)</div>
<div class="line"><span class="lineno"> 108</span> {</div>
<div class="line"><span class="lineno"> 109</span> temp = temp-&gt;rlink;</div>
<div class="line"><span class="lineno"> 110</span> }</div>
<div class="line"><span class="lineno"> 111</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 112</span> {</div>
<div class="line"><span class="lineno"> 113</span> temp = temp-&gt;llink;</div>
<div class="line"><span class="lineno"> 114</span> }</div>
<div class="line"><span class="lineno"> 115</span> }</div>
<div class="line"><span class="lineno"> 116</span> </div>
<div class="line"><span class="lineno"> 117</span> <span class="keywordflow">if</span> (temp == NULL)</div>
<div class="line"><span class="lineno"> 118</span> {</div>
<div class="line"><span class="lineno"> 119</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Element not found.&quot;</span>);</div>
<div class="line"><span class="lineno"> 120</span> }</div>
<div class="line"><span class="lineno"> 121</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 122</span> printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <span class="stringliteral">&quot;Element found.&quot;</span>);</div>
<div class="line"><span class="lineno"> 123</span>}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html">data_structures</a></li><li class="navelem"><a class="el" href="../../dir_e39df94f82619fa5256f1786519937be.html">binary_trees</a></li><li class="navelem"><a class="el" href="../../df/d3c/threaded__binary__trees_8c.html">threaded_binary_trees.c</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.9.5 </li>
</ul>
</div>
</body>
</html>