{"id":76201,"date":"2024-07-28T16:46:11","date_gmt":"2024-07-28T20:46:11","guid":{"rendered":"https:\/\/bangla.sitestree.com\/?p=76201"},"modified":"2024-07-28T17:02:53","modified_gmt":"2024-07-28T21:02:53","slug":"steps-to-create-a-binary-search-tree","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=76201","title":{"rendered":"Steps to Create a Binary Search Tree"},"content":{"rendered":"\n<p><br \/>If binary tree is empty, create a node, and assign data, point to it<br \/>Otherwise : point to root node<\/p>\n\n\n\n<p><br \/>Compare the new &#8211; data &#8211; to &#8211; insert with the current node data<br \/>We maintain a pointer say current to point to the node under visit<\/p>\n\n\n\n<p><br \/>If data matched : nothing to do<br \/>If data does not match :<br \/>keep traversing left if new data is smaller than current node data(until match or reach leaf \/ null).<br \/><\/p>\n\n\n\n<p>To keep traversing to the left : current = current->left<br \/>Then create a new node, and point the left of curr node to this new node<br \/><\/p>\n\n\n\n<p>keep traversing right if new data is bigger than current node data(until match or reach leaf \/ null).<br \/><\/p>\n\n\n\n<p>To keep traversing to the right : current = current->right<br \/>Then create a new node, and point the right of current node to this new node<br \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If binary tree is empty, create a node, and assign data, point to itOtherwise : point to root node Compare the new &#8211; data &#8211; to &#8211; insert with the current node dataWe maintain a pointer say current to point to the node under visit If data matched : nothing to doIf data does not &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=76201\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1966,1883,182],"tags":[],"class_list":["post-76201","post","type-post","status-publish","format-standard","hentry","category-data-structure-and-algorithms","category---data-structure","category---blog","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":76187,"url":"http:\/\/bangla.sitestree.com\/?p=76187","url_meta":{"origin":76201,"position":0},"title":"C Code Build a Binary Tree.","author":"Sayed","date":"July 20, 2024","format":false,"excerpt":"#include <iostream> #include <string.h> #include <stdlib.h> #pragma warning(disable : 4996) #define MaxWordSize 100 \/\/ Declare a structure that holds data in a node typedef struct { char word[MaxWordSize + 1]; } NodeData; typedef struct treeNode { NodeData data; struct treeNode* left, * right; } TreeNode, *TreeNodePtr; typedef struct { TreeNodePtr\u2026","rel":"","context":"In &quot;Data Structure and Algorithms&quot;","block_context":{"text":"Data Structure and Algorithms","link":"http:\/\/bangla.sitestree.com\/?cat=1966"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26964,"url":"http:\/\/bangla.sitestree.com\/?p=26964","url_meta":{"origin":76201,"position":1},"title":"TreeTest.java Builds a binary tree and prints the contents of the nodes. Uses the following classes: #Programming Code Examples #Java\/J2EE\/J2ME #Basic Java","author":"Author-Check- Article-or-Video","date":"May 6, 2021","format":false,"excerpt":"Treetest.java \/** A NodeOperator that prints each node. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ class PrintOperator implements NodeOperator { public void operateOn(Node node)\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10508,"url":"http:\/\/bangla.sitestree.com\/?p=10508","url_meta":{"origin":76201,"position":2},"title":"TreeTest.java Builds a binary tree and prints the contents of the nodes. Uses the following classes:","author":"","date":"August 29, 2015","format":false,"excerpt":"Treetest.java \/** A NodeOperator that prints each node. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown; \u00a0*\u00a0 may be freely used or adapted. \u00a0*\/ class PrintOperator implements NodeOperator { \u00a0 public void operateOn(Node\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":76203,"url":"http:\/\/bangla.sitestree.com\/?p=76203","url_meta":{"origin":76201,"position":3},"title":"Pre Order Traversal of a Binary Tree in C","author":"Sayed","date":"July 28, 2024","format":false,"excerpt":"\/\/ pre order traversalvoid preOrder(NodePtr node) {if (node != NULL) { printf(\"%s \", node->data.word); preOrder(node->left); preOrder(node->right);}}","rel":"","context":"In &quot;Data Structure and Algorithms&quot;","block_context":{"text":"Data Structure and Algorithms","link":"http:\/\/bangla.sitestree.com\/?cat=1966"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":76205,"url":"http:\/\/bangla.sitestree.com\/?p=76205","url_meta":{"origin":76201,"position":4},"title":"Binary Tree Traversal in Post Order: In C","author":"Sayed","date":"July 28, 2024","format":false,"excerpt":"\/\/ traverse the tree in post-order basis \/\/ print the treee content in post-order basis void postOrder(NodePtr node) { if (node != NULL) { postOrder(node->left); postOrder(node->right); printf(\"%s \", node->data.word); } }","rel":"","context":"In &quot;Data Structure and Algorithms&quot;","block_context":{"text":"Data Structure and Algorithms","link":"http:\/\/bangla.sitestree.com\/?cat=1966"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":76207,"url":"http:\/\/bangla.sitestree.com\/?p=76207","url_meta":{"origin":76201,"position":5},"title":"Binary Tree Traversal using In Order: In C","author":"Sayed","date":"July 28, 2024","format":false,"excerpt":"\/\/ traverse the tree in in-order basis \/\/ print the treee content in in-order basis void inOrder(NodePtr node) { if (node != NULL) { inOrder(node->left); printf(\"%s \", node->data.word); inOrder(node->right); } }","rel":"","context":"In &quot;Data Structure and Algorithms&quot;","block_context":{"text":"Data Structure and Algorithms","link":"http:\/\/bangla.sitestree.com\/?cat=1966"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76201"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76201\/revisions"}],"predecessor-version":[{"id":76202,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76201\/revisions\/76202"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76201"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}