TheAlgorithms-C/df/d3c/threaded__binary__trees_8c.html

635 lines
60 KiB
HTML
Raw Normal View History

<!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">
<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.2"/>
<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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<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.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</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="170" height="142"><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;&nbsp;</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"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span>{</div>
<div class="line"><a id="l00040" name="l00040"></a><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"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> ptr-&gt;rlink = ptr-&gt;llink = NULL;</div>
<div class="line"><a id="l00042" name="l00042"></a><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"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <span class="keywordflow">return</span> ptr;</div>
<div class="line"><a id="l00044" name="l00044"></a><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;&nbsp;</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"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span>{</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *temp;</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *prev;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <span class="keywordflow">if</span> (*root == NULL)</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> {</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> temp = *root;</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> prev = NULL;</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> <span class="comment">// search</span></div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> {</div>
<div class="line"><a id="l00186" name="l00186"></a><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"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> {</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> }</div>
<div class="line"><a id="l00190" name="l00190"></a><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"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> {</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> prev = temp;</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> temp = temp-&gt;rlink;</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> }</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> {</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> prev = temp;</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> temp = temp-&gt;llink;</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> }</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> }</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span> }</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span> </div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span> <span class="keywordflow">if</span> (temp == NULL)</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> {</div>
<div class="line"><a id="l00207" name="l00207"></a><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"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *t;</div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <span class="keywordflow">if</span> (temp-&gt;llink == NULL &amp;&amp; temp-&gt;rlink == NULL)</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> {</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> replacement = NULL;</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> }</div>
<div class="line"><a id="l00213" name="l00213"></a><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"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> {</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> replacement = temp-&gt;rlink;</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> }</div>
<div class="line"><a id="l00217" name="l00217"></a><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"><a id="l00218" name="l00218"></a><span class="lineno"> 218</span> {</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno"> 219</span> replacement = temp-&gt;llink;</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"> 220</span> }</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> {</div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span> replacement = temp-&gt;rlink; <span class="comment">// replaced with inorder successor</span></div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span> t = replacement;</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno"> 225</span> <span class="keywordflow">while</span> (t-&gt;llink != NULL)</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno"> 226</span> {</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"> 227</span> t = t-&gt;llink;</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno"> 228</span> }</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno"> 229</span> t-&gt;llink =</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno"> 230</span> temp-&gt;llink; <span class="comment">// leftmost node of the replacement is linked to</span></div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"> 231</span> <span class="comment">// the left child of the deleted node</span></div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno"> 232</span> }</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"> 233</span> </div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno"> 234</span> <span class="keywordflow">if</span> (temp == *root)</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno"> 235</span> {</div>
<div class="line"><a id="l00236" name="l00236"></a><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"><a id="l00237" name="l00237"></a><span class="lineno"> 237</span> *root = replacement;</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno"> 238</span> }</div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno"> 239</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (prev-&gt;llink == temp)</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno"> 240</span> {</div>
<div class="line"><a id="l00241" name="l00241"></a><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"><a id="l00242" name="l00242"></a><span class="lineno"> 242</span> prev-&gt;llink = replacement;</div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"> 243</span> }</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno"> 244</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (prev-&gt;rlink == temp)</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno"> 245</span> {</div>
<div class="line"><a id="l00246" name="l00246"></a><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"><a id="l00247" name="l00247"></a><span class="lineno"> 247</span> prev-&gt;rlink = replacement;</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno"> 248</span> }</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno"> 249</span> }</div>
<div class="line"><a id="l00250" name="l00250"></a><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;&nbsp;</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"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span>{</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> {</div>
<div class="line"><a id="l00133" name="l00133"></a><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"><a id="l00134" name="l00134"></a><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"><a id="l00135" name="l00135"></a><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"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> }</div>
<div class="line"><a id="l00137" name="l00137"></a><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="123" height="62"><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;&nbsp;</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"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span>{</div>
<div class="line"><a id="l00053" name="l00053"></a><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"><a id="l00054" name="l00054"></a><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"><a id="l00055" name="l00055"></a><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"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="keywordflow">if</span> (*root == NULL)</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> {</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> *root = new_node;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> }</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> temp = *root;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> prev = NULL;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> {</div>
<div class="line"><a id="l00066" name="l00066"></a><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"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> {</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> prev = temp;</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> temp = temp-&gt;rlink;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> }</div>
<div class="line"><a id="l00071" name="l00071"></a><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"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> {</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> prev = temp;</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> temp = temp-&gt;llink;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> }</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> {</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> }</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> }</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> </div>
<div class="line"><a id="l00082" name="l00082"></a><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"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> {</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> prev-&gt;rlink = new_node;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> }</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> {</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> prev-&gt;llink = new_node;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> }</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> }</div>
<div class="line"><a id="l00091" name="l00091"></a><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="228" height="38"><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;&nbsp;</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"><a id="l00256" name="l00256"></a><span class="lineno"> 256</span>{</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno"> 257</span> printf(<span class="stringliteral">&quot;BINARY THREADED TREE: \n&quot;</span>);</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno"> 258</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *root = NULL;</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno"> 259</span> <span class="keywordtype">int</span> choice, n;</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno"> 260</span> <span class="keywordflow">do</span></div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno"> 261</span> {</div>
<div class="line"><a id="l00262" name="l00262"></a><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"><a id="l00263" name="l00263"></a><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"><a id="l00264" name="l00264"></a><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"><a id="l00265" name="l00265"></a><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"><a id="l00266" name="l00266"></a><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"><a id="l00267" name="l00267"></a><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"><a id="l00268" name="l00268"></a><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"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;choice);</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno"> 270</span> </div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno"> 271</span> <span class="keywordflow">switch</span> (choice)</div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno"> 272</span> {</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno"> 273</span> <span class="keywordflow">case</span> 1:</div>
<div class="line"><a id="l00274" name="l00274"></a><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"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><a id="l00276" name="l00276"></a><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"><a id="l00277" name="l00277"></a><span class="lineno"> 277</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno"> 278</span> <span class="keywordflow">case</span> 2:</div>
<div class="line"><a id="l00279" name="l00279"></a><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"><a id="l00280" name="l00280"></a><span class="lineno"> 280</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno"> 281</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno"> 282</span> <span class="keywordflow">case</span> 3:</div>
<div class="line"><a id="l00283" name="l00283"></a><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"><a id="l00284" name="l00284"></a><span class="lineno"> 284</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno"> 285</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno"> 286</span> <span class="keywordflow">case</span> 4:</div>
<div class="line"><a id="l00287" name="l00287"></a><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"><a id="l00288" name="l00288"></a><span class="lineno"> 288</span> printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno"> 289</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno"> 290</span> <span class="keywordflow">case</span> 5:</div>
<div class="line"><a id="l00291" name="l00291"></a><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"><a id="l00292" name="l00292"></a><span class="lineno"> 292</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><a id="l00293" name="l00293"></a><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"><a id="l00294" name="l00294"></a><span class="lineno"> 294</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno"> 295</span> <span class="keywordflow">case</span> 6:</div>
<div class="line"><a id="l00296" name="l00296"></a><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"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span> scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;n);</div>
<div class="line"><a id="l00298" name="l00298"></a><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"><a id="l00299" name="l00299"></a><span class="lineno"> 299</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno"> 300</span> }</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"> 301</span> } <span class="keywordflow">while</span> (choice != 0);</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno"> 302</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00303" name="l00303"></a><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="380" height="363"><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;&nbsp;</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"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span>{</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> {</div>
<div class="line"><a id="l00147" name="l00147"></a><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"><a id="l00148" name="l00148"></a><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"><a id="l00149" name="l00149"></a><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"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> }</div>
<div class="line"><a id="l00151" name="l00151"></a><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="138" height="62"><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;&nbsp;</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"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span>{</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> <span class="keywordflow">if</span> (curr != NULL)</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> {</div>
<div class="line"><a id="l00161" name="l00161"></a><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"><a id="l00162" name="l00162"></a><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"><a id="l00163" name="l00163"></a><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"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> }</div>
<div class="line"><a id="l00165" name="l00165"></a><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="132" height="62"><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;&nbsp;</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"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span>{</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> *temp = root;</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> <span class="keywordflow">while</span> (temp != NULL)</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> {</div>
<div class="line"><a id="l00103" name="l00103"></a><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"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> {</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> }</div>
<div class="line"><a id="l00107" name="l00107"></a><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"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> temp = temp-&gt;rlink;</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> }</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> {</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> temp = temp-&gt;llink;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> }</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> }</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> </div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="keywordflow">if</span> (temp == NULL)</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> {</div>
<div class="line"><a id="l00119" name="l00119"></a><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"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> }</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00122" name="l00122"></a><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"><a id="l00123" name="l00123"></a><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.2 </li>
</ul>
</div>
</body>
</html>