2020-06-28 23:07:29 +08:00
<!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=9" / >
2021-02-06 03:52:57 +08:00
< meta name = "generator" content = "Doxygen 1.9.1" / >
2020-06-28 23:07:29 +08:00
< 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" > 1.0.0< / span >
< / div >
< div id = "projectbrief" > Set of algorithms implemented in C.< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2021-02-06 03:52:57 +08:00
<!-- Generated by Doxygen 1.9.1 -->
2020-06-28 23:07:29 +08:00
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
2021-02-06 03:52:57 +08:00
var searchBox = new SearchBox("searchBox", "../../search",false,'Search','.html');
2020-06-28 23:07:29 +08:00
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
$(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:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
$(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 > |
< a href = "#typedef-members" > Typedefs< / a > |
< 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 < stdio.h> < / code > < br / >
< code > #include < stdlib.h> < / 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 = "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 name = "nested-classes" > < / a >
Data Structures< / h2 > < / td > < / tr >
< tr class = "memitem:" > < td class = "memItemLeft" align = "right" valign = "top" > struct   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../db/d8b/struct_node.html" > Node< / a > < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memdesc:" > < td class = "mdescLeft" >   < / 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 >
2020-06-28 23:07:29 +08:00
< tr class = "separator:" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a name = "typedef-members" > < / a >
Typedefs< / h2 > < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:ad8ecdcce462dd8e170ae1f164935aaa6" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "ad8ecdcce462dd8e170ae1f164935aaa6" > < / a >
typedef struct < a class = "el" href = "../../db/d8b/struct_node.html" > Node< / a >   < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/d3c/threaded__binary__trees_8c.html#ad8ecdcce462dd8e170ae1f164935aaa6" > node< / a > < / td > < / tr >
< tr class = "memdesc:ad8ecdcce462dd8e170ae1f164935aaa6" > < td class = "mdescLeft" >   < / 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 >
2020-06-28 23:07:29 +08:00
< tr class = "separator:ad8ecdcce462dd8e170ae1f164935aaa6" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a name = "func-members" > < / a >
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:ab21d1d36d95001defbca2f6abd4d410c" > < td class = "memItemLeft" align = "right" valign = "top" > < a class = "el" href = "../../d5/da1/structnode.html" > node< / a > *  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/d3c/threaded__binary__trees_8c.html#ab21d1d36d95001defbca2f6abd4d410c" > create_node< / a > (int < a class = "el" href = "../../df/dea/structdata.html" > data< / a > )< / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memdesc:ab21d1d36d95001defbca2f6abd4d410c" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > creates a new node param[in] data value to be inserted < a href = "../../df/d3c/threaded__binary__trees_8c.html#ab21d1d36d95001defbca2f6abd4d410c" > More...< / a > < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:ab21d1d36d95001defbca2f6abd4d410c" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:a823432888332fc9f0aa6072cff28c3bb" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "a823432888332fc9f0aa6072cff28c3bb" > < / a >
void  < / 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" >   < / 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 < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a823432888332fc9f0aa6072cff28c3bb" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a306d567466f22e1e927aaed97d8bb58c" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / 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 >
2020-06-29 04:40:24 +08:00
< tr class = "memdesc:a306d567466f22e1e927aaed97d8bb58c" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > searches for the element < a href = "../../df/d3c/threaded__binary__trees_8c.html#a306d567466f22e1e927aaed97d8bb58c" > More...< / a > < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a306d567466f22e1e927aaed97d8bb58c" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:a4c1e06b5f0876ec9c1bd6817f3b7eda7" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "a4c1e06b5f0876ec9c1bd6817f3b7eda7" > < / a >
void  < / 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" >   < / td > < td class = "mdescRight" > performs inorder traversal param[in] curr node pointer to the topmost node of the tree < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a4c1e06b5f0876ec9c1bd6817f3b7eda7" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:a5a82ae0ee13788be51ca4ba6cddb0719" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "a5a82ae0ee13788be51ca4ba6cddb0719" > < / a >
void  < / 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" >   < / td > < td class = "mdescRight" > performs postorder traversal param[in] curr node pointer to the topmost node of the tree < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a5a82ae0ee13788be51ca4ba6cddb0719" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:a8169ba0dfd5b8183672e444d1434bf9c" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "a8169ba0dfd5b8183672e444d1434bf9c" > < / a >
void  < / 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" >   < / td > < td class = "mdescRight" > performs preorder traversal param[in] curr node pointer to the topmost node of the tree < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a8169ba0dfd5b8183672e444d1434bf9c" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a284d683f74b6c884e79ba00d3d1c3317" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / 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 >
2020-06-29 04:40:24 +08:00
< tr class = "memdesc:a284d683f74b6c884e79ba00d3d1c3317" > < td class = "mdescLeft" >   < / 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 >
2020-06-28 23:07:29 +08:00
< tr class = "separator:a284d683f74b6c884e79ba00d3d1c3317" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-06-29 04:40:24 +08:00
< tr class = "memitem:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "ae66f6b31b5ad750f1fe042a706a4e3d4" > < / a >
int  < / 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" >   < / td > < td class = "mdescRight" > main function < br / > < / td > < / tr >
2020-06-28 23:07:29 +08:00
< tr class = "separator:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memSeparator" colspan = "2" >   < / 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 >
2020-07-22 20:41:17 +08:00
< 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 >
2020-06-28 23:07:29 +08:00
< dl class = "section author" > < dt > Author< / dt > < dd > < a href = "https://github.com/amitnayakblr" > Amitha Nayak< / a > < / dd > < / dl >
2020-06-29 04:40:24 +08:00
< / div > < h2 class = "groupheader" > Function Documentation< / h2 >
2020-06-28 23:07:29 +08:00
< a id = "ab21d1d36d95001defbca2f6abd4d410c" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ab21d1d36d95001defbca2f6abd4d410c" > ◆ < / 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  < / td >
< td class = "paramname" > < em > data< / em > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
2020-06-29 04:40:24 +08:00
< 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 >
2020-06-28 23:07:29 +08:00
< div class = "fragment" > < div class = "line" > < a name = "l00039" > < / a > < span class = "lineno" > 39< / span >   {< / div >
< div class = "line" > < a name = "l00040" > < / a > < span class = "lineno" > 40< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *ptr = (< a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *)malloc(< span class = "keyword" > sizeof< / span > (< a class = "code" href = "../../d5/da1/structnode.html" > node< / a > ));< / div >
< div class = "line" > < a name = "l00041" > < / a > < span class = "lineno" > 41< / span >   ptr-> rlink = ptr-> llink = NULL;< / div >
2020-07-22 20:41:17 +08:00
< div class = "line" > < a name = "l00042" > < / a > < span class = "lineno" > 42< / span >   ptr-> < a class = "code" href = "../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2" > data< / a > = < a class = "code" href = "../../df/dea/structdata.html" > data< / a > ;< / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00043" > < / a > < span class = "lineno" > 43< / span >   < span class = "keywordflow" > return< / span > ptr;< / div >
< div class = "line" > < a name = "l00044" > < / a > < span class = "lineno" > 44< / span >   }< / div >
2021-02-06 03:52:57 +08:00
< 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 >
2020-06-28 23:07:29 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
< a id = "a284d683f74b6c884e79ba00d3d1c3317" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a284d683f74b6c884e79ba00d3d1c3317" > ◆ < / 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 > **  < / td >
< td class = "paramname" > < em > root< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > ele< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
2020-06-29 04:40:24 +08:00
< 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 >
2020-06-28 23:07:29 +08:00
< div class = "fragment" > < div class = "line" > < a name = "l00174" > < / a > < span class = "lineno" > 174< / span >   {< / div >
< div class = "line" > < a name = "l00175" > < / a > < span class = "lineno" > 175< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *temp;< / div >
< div class = "line" > < a name = "l00176" > < / a > < span class = "lineno" > 176< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *prev;< / div >
< div class = "line" > < a name = "l00177" > < / a > < span class = "lineno" > 177< / span >   < span class = "keywordflow" > if< / span > (*root == NULL)< / div >
< div class = "line" > < a name = "l00178" > < / a > < span class = "lineno" > 178< / span >   < span class = "keywordflow" > return< / span > ;< / div >
< div class = "line" > < a name = "l00179" > < / a > < span class = "lineno" > 179< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00180" > < / a > < span class = "lineno" > 180< / span >   {< / div >
< div class = "line" > < a name = "l00181" > < / a > < span class = "lineno" > 181< / span >   temp = *root;< / div >
< div class = "line" > < a name = "l00182" > < / a > < span class = "lineno" > 182< / span >   prev = NULL;< / div >
< div class = "line" > < a name = "l00183" > < / a > < span class = "lineno" > 183< / span >   < span class = "comment" > // search< / span > < / div >
< div class = "line" > < a name = "l00184" > < / a > < span class = "lineno" > 184< / span >   < span class = "keywordflow" > while< / span > (temp != NULL)< / div >
< div class = "line" > < a name = "l00185" > < / a > < span class = "lineno" > 185< / span >   {< / div >
2020-07-22 20:41:17 +08:00
< div class = "line" > < a name = "l00186" > < / a > < span class = "lineno" > 186< / span >   < span class = "keywordflow" > if< / span > (temp-> < a class = "code" href = "../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2" > data< / a > == ele)< / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00187" > < / a > < span class = "lineno" > 187< / span >   {< / div >
< div class = "line" > < a name = "l00188" > < / a > < span class = "lineno" > 188< / span >   < span class = "keywordflow" > break< / span > ;< / div >
< div class = "line" > < a name = "l00189" > < / a > < span class = "lineno" > 189< / span >   }< / div >
2020-07-22 20:41:17 +08:00
< div class = "line" > < a name = "l00190" > < / a > < span class = "lineno" > 190< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (ele > temp-> < a class = "code" href = "../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2" > data< / a > )< / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00191" > < / a > < span class = "lineno" > 191< / span >   {< / div >
< div class = "line" > < a name = "l00192" > < / a > < span class = "lineno" > 192< / span >   prev = temp;< / div >
< div class = "line" > < a name = "l00193" > < / a > < span class = "lineno" > 193< / span >   temp = temp-> rlink;< / div >
< div class = "line" > < a name = "l00194" > < / a > < span class = "lineno" > 194< / span >   }< / div >
< div class = "line" > < a name = "l00195" > < / a > < span class = "lineno" > 195< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00196" > < / a > < span class = "lineno" > 196< / span >   {< / div >
< div class = "line" > < a name = "l00197" > < / a > < span class = "lineno" > 197< / span >   prev = temp;< / div >
< div class = "line" > < a name = "l00198" > < / a > < span class = "lineno" > 198< / span >   temp = temp-> llink;< / div >
< div class = "line" > < a name = "l00199" > < / a > < span class = "lineno" > 199< / span >   }< / div >
< div class = "line" > < a name = "l00200" > < / a > < span class = "lineno" > 200< / span >   }< / div >
< div class = "line" > < a name = "l00201" > < / a > < span class = "lineno" > 201< / span >   }< / div >
< div class = "line" > < a name = "l00202" > < / a > < span class = "lineno" > 202< / span >   < / div >
< div class = "line" > < a name = "l00203" > < / a > < span class = "lineno" > 203< / span >   < span class = "keywordflow" > if< / span > (temp == NULL)< / div >
< div class = "line" > < a name = "l00204" > < / a > < span class = "lineno" > 204< / span >   < span class = "keywordflow" > return< / span > ;< / div >
< div class = "line" > < a name = "l00205" > < / a > < span class = "lineno" > 205< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00206" > < / a > < span class = "lineno" > 206< / span >   {< / div >
2020-06-28 23:30:37 +08:00
< div class = "line" > < a name = "l00207" > < / a > < span class = "lineno" > 207< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *replacement; < span class = "comment" > // deleted node' s replacement< / span > < / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00208" > < / a > < span class = "lineno" > 208< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *t;< / div >
< div class = "line" > < a name = "l00209" > < / a > < span class = "lineno" > 209< / span >   < span class = "keywordflow" > if< / span > (temp-> llink == NULL & & temp-> rlink == NULL)< / div >
< div class = "line" > < a name = "l00210" > < / a > < span class = "lineno" > 210< / span >   {< / div >
< div class = "line" > < a name = "l00211" > < / a > < span class = "lineno" > 211< / span >   replacement = NULL;< / div >
< div class = "line" > < a name = "l00212" > < / a > < span class = "lineno" > 212< / span >   }< / div >
< div class = "line" > < a name = "l00213" > < / a > < span class = "lineno" > 213< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (temp-> llink == NULL & & temp-> rlink != NULL)< / div >
< div class = "line" > < a name = "l00214" > < / a > < span class = "lineno" > 214< / span >   {< / div >
< div class = "line" > < a name = "l00215" > < / a > < span class = "lineno" > 215< / span >   replacement = temp-> rlink;< / div >
< div class = "line" > < a name = "l00216" > < / a > < span class = "lineno" > 216< / span >   }< / div >
< div class = "line" > < a name = "l00217" > < / a > < span class = "lineno" > 217< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (temp-> llink != NULL & & temp-> rlink == NULL)< / div >
< div class = "line" > < a name = "l00218" > < / a > < span class = "lineno" > 218< / span >   {< / div >
< div class = "line" > < a name = "l00219" > < / a > < span class = "lineno" > 219< / span >   replacement = temp-> llink;< / div >
< div class = "line" > < a name = "l00220" > < / a > < span class = "lineno" > 220< / span >   }< / div >
< div class = "line" > < a name = "l00221" > < / a > < span class = "lineno" > 221< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00222" > < / a > < span class = "lineno" > 222< / span >   {< / div >
2020-06-28 23:30:37 +08:00
< div class = "line" > < a name = "l00223" > < / a > < span class = "lineno" > 223< / span >   replacement = temp-> rlink; < span class = "comment" > // replaced with inorder successor< / span > < / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00224" > < / a > < span class = "lineno" > 224< / span >   t = replacement;< / div >
< div class = "line" > < a name = "l00225" > < / a > < span class = "lineno" > 225< / span >   < span class = "keywordflow" > while< / span > (t-> llink != NULL)< / div >
< div class = "line" > < a name = "l00226" > < / a > < span class = "lineno" > 226< / span >   {< / div >
< div class = "line" > < a name = "l00227" > < / a > < span class = "lineno" > 227< / span >   t = t-> llink;< / div >
< div class = "line" > < a name = "l00228" > < / a > < span class = "lineno" > 228< / span >   }< / div >
< div class = "line" > < a name = "l00229" > < / a > < span class = "lineno" > 229< / span >   t-> llink =< / div >
2020-06-28 23:30:37 +08:00
< div class = "line" > < a name = "l00230" > < / a > < span class = "lineno" > 230< / span >   temp-> llink; < span class = "comment" > // leftmost node of the replacement is linked to< / span > < / div >
< div class = "line" > < a name = "l00231" > < / a > < span class = "lineno" > 231< / span >   < span class = "comment" > // the left child of the deleted node< / span > < / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00232" > < / a > < span class = "lineno" > 232< / span >   }< / div >
< div class = "line" > < a name = "l00233" > < / a > < span class = "lineno" > 233< / span >   < / div >
< div class = "line" > < a name = "l00234" > < / a > < span class = "lineno" > 234< / span >   < span class = "keywordflow" > if< / span > (temp == *root)< / div >
< div class = "line" > < a name = "l00235" > < / a > < span class = "lineno" > 235< / span >   {< / div >
< div class = "line" > < a name = "l00236" > < / a > < span class = "lineno" > 236< / span >   free(*root);< / div >
< div class = "line" > < a name = "l00237" > < / a > < span class = "lineno" > 237< / span >   *root = replacement;< / div >
< div class = "line" > < a name = "l00238" > < / a > < span class = "lineno" > 238< / span >   }< / div >
< div class = "line" > < a name = "l00239" > < / a > < span class = "lineno" > 239< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (prev-> llink == temp)< / div >
< div class = "line" > < a name = "l00240" > < / a > < span class = "lineno" > 240< / span >   {< / div >
< div class = "line" > < a name = "l00241" > < / a > < span class = "lineno" > 241< / span >   free(prev-> llink);< / div >
< div class = "line" > < a name = "l00242" > < / a > < span class = "lineno" > 242< / span >   prev-> llink = replacement;< / div >
< div class = "line" > < a name = "l00243" > < / a > < span class = "lineno" > 243< / span >   }< / div >
< div class = "line" > < a name = "l00244" > < / a > < span class = "lineno" > 244< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (prev-> rlink == temp)< / div >
< div class = "line" > < a name = "l00245" > < / a > < span class = "lineno" > 245< / span >   {< / div >
< div class = "line" > < a name = "l00246" > < / a > < span class = "lineno" > 246< / span >   free(prev-> rlink);< / div >
< div class = "line" > < a name = "l00247" > < / a > < span class = "lineno" > 247< / span >   prev-> rlink = replacement;< / div >
< div class = "line" > < a name = "l00248" > < / a > < span class = "lineno" > 248< / span >   }< / div >
< div class = "line" > < a name = "l00249" > < / a > < span class = "lineno" > 249< / span >   }< / div >
< div class = "line" > < a name = "l00250" > < / a > < span class = "lineno" > 250< / span >   }< / div >
< / div > <!-- fragment -->
< / div >
< / div >
< a id = "a306d567466f22e1e927aaed97d8bb58c" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a306d567466f22e1e927aaed97d8bb58c" > ◆ < / 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 > *  < / td >
< td class = "paramname" > < em > root< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > ele< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
2020-06-29 04:40:24 +08:00
< p > searches for the element < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
2020-06-28 23:07:29 +08:00
< 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 name = "l00099" > < / a > < span class = "lineno" > 99< / span >   {< / div >
< div class = "line" > < a name = "l00100" > < / a > < span class = "lineno" > 100< / span >   < a class = "code" href = "../../d5/da1/structnode.html" > node< / a > *temp = root;< / div >
< div class = "line" > < a name = "l00101" > < / a > < span class = "lineno" > 101< / span >   < span class = "keywordflow" > while< / span > (temp != NULL)< / div >
< div class = "line" > < a name = "l00102" > < / a > < span class = "lineno" > 102< / span >   {< / div >
2020-07-22 20:41:17 +08:00
< div class = "line" > < a name = "l00103" > < / a > < span class = "lineno" > 103< / span >   < span class = "keywordflow" > if< / span > (temp-> < a class = "code" href = "../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2" > data< / a > == ele)< / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00104" > < / a > < span class = "lineno" > 104< / span >   {< / div >
< div class = "line" > < a name = "l00105" > < / a > < span class = "lineno" > 105< / span >   < span class = "keywordflow" > break< / span > ;< / div >
< div class = "line" > < a name = "l00106" > < / a > < span class = "lineno" > 106< / span >   }< / div >
2020-07-22 20:41:17 +08:00
< div class = "line" > < a name = "l00107" > < / a > < span class = "lineno" > 107< / span >   < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (ele > temp-> < a class = "code" href = "../../d5/da1/structnode.html#a2d890bb9f6af0ffd73fe79b21124c2a2" > data< / a > )< / div >
2020-06-28 23:07:29 +08:00
< div class = "line" > < a name = "l00108" > < / a > < span class = "lineno" > 108< / span >   {< / div >
< div class = "line" > < a name = "l00109" > < / a > < span class = "lineno" > 109< / span >   temp = temp-> rlink;< / div >
< div class = "line" > < a name = "l00110" > < / a > < span class = "lineno" > 110< / span >   }< / div >
< div class = "line" > < a name = "l00111" > < / a > < span class = "lineno" > 111< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00112" > < / a > < span class = "lineno" > 112< / span >   {< / div >
< div class = "line" > < a name = "l00113" > < / a > < span class = "lineno" > 113< / span >   temp = temp-> llink;< / div >
< div class = "line" > < a name = "l00114" > < / a > < span class = "lineno" > 114< / span >   }< / div >
< div class = "line" > < a name = "l00115" > < / a > < span class = "lineno" > 115< / span >   }< / div >
< div class = "line" > < a name = "l00116" > < / a > < span class = "lineno" > 116< / span >   < / div >
< div class = "line" > < a name = "l00117" > < / a > < span class = "lineno" > 117< / span >   < span class = "keywordflow" > if< / span > (temp == NULL)< / div >
< div class = "line" > < a name = "l00118" > < / a > < span class = "lineno" > 118< / span >   {< / div >
< div class = "line" > < a name = "l00119" > < / a > < span class = "lineno" > 119< / span >   printf(< span class = "stringliteral" > " %s\n" < / span > , < span class = "stringliteral" > " Element not found." < / span > );< / div >
< div class = "line" > < a name = "l00120" > < / a > < span class = "lineno" > 120< / span >   }< / div >
< div class = "line" > < a name = "l00121" > < / a > < span class = "lineno" > 121< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00122" > < / a > < span class = "lineno" > 122< / span >   printf(< span class = "stringliteral" > " %s\n" < / span > , < span class = "stringliteral" > " Element found." < / span > );< / div >
< div class = "line" > < a 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 >
2021-02-06 03:52:57 +08:00
< 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.1 < / li >
2020-06-28 23:07:29 +08:00
< / ul >
< / div >
< / body >
< / html >