<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Data Structures Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/category/data-structures/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/category/data-structures/</link>
	<description></description>
	<lastBuildDate>Mon, 11 May 2026 01:54:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>Data Structures Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/category/data-structures/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Binary Search Tree Removals &#8211; Delete Nodes with 0, 1, or 2 Children</title>
		<link>https://www.NeuralLantern.com/binary-search-tree-removals-delete-nodes-with-0-1-or-2-children/</link>
					<comments>https://www.NeuralLantern.com/binary-search-tree-removals-delete-nodes-with-0-1-or-2-children/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 11 May 2026 01:54:41 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree remove]]></category>
		<category><![CDATA[binary tree deletion]]></category>
		<category><![CDATA[bst deletion]]></category>
		<category><![CDATA[bst operations]]></category>
		<category><![CDATA[bst remove node]]></category>
		<category><![CDATA[coding interview]]></category>
		<category><![CDATA[cs data structures]]></category>
		<category><![CDATA[data structures tutorial]]></category>
		<category><![CDATA[delete node bst]]></category>
		<category><![CDATA[inorder successor]]></category>
		<category><![CDATA[tree algorithms]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=340</guid>

					<description><![CDATA[<p>So there are three types of deletions... Is it a leaf with zero children? Is it a node with one child? Or is it a node with two children? Each type of node is deleted in a different way... For the hardest type we use the in-order successor.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-removals-delete-nodes-with-0-1-or-2-children/">Binary Search Tree Removals &#8211; Delete Nodes with 0, 1, or 2 Children</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Binary Search Tree Removals - Delete Nodes with 0, 1, or 2 Children" width="1380" height="776" src="https://www.youtube.com/embed/TPAiCeiMw18?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hello there. In this video we break down exactly how to delete nodes from a binary search tree. We cover all three cases step by step: deleting a leaf node with zero children, deleting a node with one child by promoting it, and the trickiest case &#8211; deleting a node with two children using the in-order successor method.</p>



<p>You&#8217;ll see clear diagram walkthroughs, pointer manipulation explanations, and time complexity discussion for each type of removal. Perfect for computer science students, coding interview prep, or anyone strengthening their data structures knowledge.</p>



<p>We search for the node, identify its children, and handle the reconnection properly to maintain the BST properties. Includes examples for each scenario and tips for implementing in code.</p>



<p>If you&#8217;re learning BST insert, search, and now removal, this completes the core operations.</p>



<p>00:00 Introduction to BST Deletions<br>00:10 BST Review and Setup<br>00:46 Three Types of Deletions<br>00:56 Deleting a Leaf Node (Zero Children)<br>03:21 Pointer Manipulation for Leaf Deletion<br>05:25 Deleting a Node with One Child<br>07:17 Pointer Updates for One Child Deletion<br>10:09 Deleting a Node with Two Children<br>12:08 In-Order Traversal and Successor Concept<br>13:18 Finding In-Order Successor<br>14:20 Copying Successor Value and Recursive Delete<br>18:28 Deleting the Root Node Example<br>22:56 Additional One Child Successor Example<br>25:12 Time Complexity Summary<br>26:08 Closing and Outro</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there. Let&#8217;s talk about deletions in a binary search tree.</p>



<p>Okay, so hopefully at this point you already understand binary search trees</p>



<p>in all other aspects than just deleting. If you don&#8217;t, see my other videos. In my other videos,</p>



<p>we talk about how to identify a binary search tree, all the rules that define it,</p>



<p>search tree with the insert or add operation.</p>



<p>We talk about searching through a binary search tree and time complexities</p>



<p>and even drawing the diagram in a really nice and pretty way so that your trees</p>



<p>are easier to debug.</p>



<p>So for now, I&#8217;m just going to say it&#8217;s time to learn how to delete notes from</p>



<p>a binary search tree.</p>



<p>So there are three types of deletions.</p>



<p>Actually, let me just kind of like, for example,</p>



<p>suppose you want to delete to delete the number 48 from the tree.</p>



<p>48 from the tree. Okay. Well, first you&#8217;d have to go search for 48. So already, you know,</p>



<p>this is going to be an O of H operation or log time. If the tree was perfectly balanced</p>



<p>or linear, if the tree was really poorly balanced. So we&#8217;re going to search for,</p>



<p>what did I just say? 48. I should write it down. Let&#8217;s say we&#8217;re going to search for 48.</p>



<p>We have to go search for it first. So that&#8217;s going to be O of H. Once we find it, we then</p>



<p>How many children does it have?</p>



<p>Is it a leaf with zero children?</p>



<p>Is it a node with one child?</p>



<p>Or is it a node with two children?</p>



<p>Each type of node is deleted in a different way.</p>



<p>So let&#8217;s see, the first type we would delete</p>



<p>is a node with zero children,</p>



<p>also known as a leaf, also known as a, sorry, external node.</p>



<p>The second type of deletion is a node with one child.</p>



<p>with one child and the third type is going to be the hardest type we&#8217;ll do that at the end of the</p>



<p>video it&#8217;s going to be a node with two children uh numbers two and three are going to be internal</p>



<p>nodes but i hope you already know that because you watch the videos anyway so let&#8217;s start off</p>



<p>with the easiest possible node to delete first just a regular leaf so i&#8217;m going to delete this</p>



<p>stuff real quick um and then just kind of like erase that and down and down okay so let&#8217;s identify</p>



<p>so let&#8217;s identify a leaf well it could be anything that just doesn&#8217;t have any</p>



<p>children of its own let&#8217;s do let&#8217;s do the number 11 just to make things a</p>



<p>little bit easier so let&#8217;s delete the number 11 I&#8217;ll put 11 here we first</p>



<p>search for 11 so we look at the root node 11 belongs on the left we look down</p>



<p>here 11 belongs on the left we look down here 11 belongs on the right we find 11</p>



<p>you know if we reach the end of the tree and we couldn&#8217;t find it then it&#8217;s like I</p>



<p>don&#8217;t know maybe throw an exception at the user hey you tried to delete</p>



<p>tried to delete something that wasn&#8217;t there but the 11 is there and now we have to figure out how</p>



<p>to actually delete it so let me draw a couple of larger representations of these nodes real fast</p>



<p>i&#8217;m just going to draw like a big old circle here and maybe duplicate it and we&#8217;ll just pretend that</p>



<p>that&#8217;s the 9 and the 11 so i&#8217;ll put like a tiny little 9 there because i don&#8217;t want to change the</p>



<p>And when we draw our diagrams, we usually just kind of do one line.</p>



<p>But you should know that if you&#8217;re doing this in code,</p>



<p>actually what&#8217;s happening is the nine node,</p>



<p>it&#8217;s got a right child pointer that points down to the 11 node.</p>



<p>And then the 11 node has a, let me just redo this real fast to make it prettier.</p>



<p>And then the 11 node has a parent pointer that points up to the nine.</p>



<p>This is probably going to be true for almost every language,</p>



<p>at least that I can think of that you would code a tree in.</p>



<p>a tree in. And then of course the nine would have a parent pointer to you know the 16 but we won&#8217;t</p>



<p>consider that. So what are you really going to do? Well first you have to look at the 11 node and</p>



<p>travel up to its parent and let the parent know that it no longer has a right child. So long story</p>



<p>short we&#8217;re going to null the right child pointer. We&#8217;re going to say disconnect that right child by</p>



<p>setting it to null. Maybe I&#8217;ll just put like a little null symbol here. Then we don&#8217;t necessarily</p>



<p>null the pointer on the 11 node because we can just delete the 11 node if we&#8217;re</p>



<p>using dynamic memory if we&#8217;re using a smart pointer it should go away already</p>



<p>at this point because it has no one else pointing to it but long story short</p>



<p>once we kill the 11 node we also end up killing its pointer so we don&#8217;t really</p>



<p>need to tell its pointer to point to null it&#8217;s just going to end up going away</p>



<p>it&#8217;s not going to be a memory leak because it was only pointing to the 9</p>



<p>and the 9 is not going to leak memory because the 9 is still going to be inside</p>



<p>going to be inside of the tree so uh the time complexity once we find the the leaf the node</p>



<p>with zero children is just going to be constant time we&#8217;re just going to manipulate a couple</p>



<p>pointers maybe call delete on that node so it&#8217;s really all about log time to go find the node if</p>



<p>it was perfectly balanced or just o of h to find it and then plus constant is going to get cancelled</p>



<p>out so it&#8217;s like an o of h operation or log time if the tree is perfect so let me just uh</p>



<p>cross it out to let you know that this is what it&#8217;s going to be like.</p>



<p>We&#8217;re going to say the 11 is just gone,</p>



<p>and so is the pointer that the 9 has pointing down to the 11.</p>



<p>That&#8217;s how you delete a node with zero children.</p>



<p>So deleted a leaf.</p>



<p>All right, now the next thing, which is slightly harder, but not too hard,</p>



<p>is deleting a node that has one child.</p>



<p>Long story short for this, we&#8217;re pretty much just going to…</p>



<p>oh I forgot to full screen the annotator let me do that to get myself a little more room</p>



<p>we&#8217;re really just going to promote its one child to wherever that node was so let me erase this</p>



<p>real fast and we&#8217;ll say that let&#8217;s first let&#8217;s find a node with only one child it&#8217;s not the 35</p>



<p>it&#8217;s the 32 node okay I guess that&#8217;s why I drew that so let&#8217;s kill the number 32</p>



<p>You know, if there was just like one child, like let&#8217;s say the 23 was the only node that existed</p>



<p>and there were no nodes underneath the 23, then this would really be the same operation. We would</p>



<p>literally just promote the 23 up to where the 32 was. But I wanted to do this example because it&#8217;s</p>



<p>a little bit more difficult. So we want to kill the 32. What we&#8217;re going to do is first search</p>



<p>for it. So this is already going to be an O of H operation or a log time if the tree is perfectly</p>



<p>We do, we go down here, we go down there.</p>



<p>You know, where is the 32?</p>



<p>We&#8217;re just searching for it.</p>



<p>So we had to spend the time to search for the node.</p>



<p>We then look at the node.</p>



<p>Okay, we found the 32.</p>



<p>We identify how many children it has.</p>



<p>We see that this is a node with only one child.</p>



<p>And that means the one child, which in this case is 23, just needs to be promoted up to where the 32 is.</p>



<p>just you know remove the 32 from the diagram maybe get rid of get get rid of one of these uh</p>



<p>connecting lines and then just move the 23 up a level and that&#8217;s pretty much it if you&#8217;re thinking</p>



<p>about this in terms of code uh you you want to have let&#8217;s see let me duplicate this again in a</p>



<p>different way if you&#8217;re thinking about code what you want to do is have the 32 which is the node</p>



<p>you&#8217;re going to delete go to its child so determine if it&#8217;s the left child or the right</p>



<p>or the right child that exists once you find that child you tell it that its new parent is the</p>



<p>parent of the node you&#8217;re trying to delete so that means the parent of the 23 is no longer 32 the</p>



<p>parent of the 23 is actually 35 you know it&#8217;s its original grandparent or the the parent of the node</p>



<p>you&#8217;re trying to delete after you do that you tell the grandparent that it&#8217;s no longer pointing down</p>



<p>to the node you&#8217;re trying to delete but instead to its grandchild so again we&#8217;re just going to</p>



<p>So again, we&#8217;re just going to manipulate some pointers here.</p>



<p>We&#8217;re going to say, yep, your left child is now the 23 and not the 32.</p>



<p>Notice how we&#8217;re kind of, you know, drawing arrows around the original node.</p>



<p>We&#8217;re sort of cutting it out of the situation, just like in a linked list where you remove one node.</p>



<p>And this is going to be a constant time operation, at least after we search and find the 32 node.</p>



<p>Finally, of course, you want to like delete the 32.</p>



<p>you have in your tree you would call delete on it depending on your language and then uh if it was</p>



<p>a smart pointer uh as soon as no other nodes are pointing to the 32 it&#8217;s just going to go away so</p>



<p>you don&#8217;t really have to worry about it but yeah long story short uh notice how the 23 is actually</p>



<p>the new left child of the 35 so that&#8217;s why i say that the the uh the one child that was on the 32</p>



<p>is going to get promoted uh to wherever the 32 was wherever the node you wanted to delete was</p>



<p>this will be the same whether or not whether it&#8217;s the left child or the right child in terms of what</p>



<p>is the one child that the node had and also you know how do you decide how to tell the the</p>



<p>grandparent is its left child pointer going to be changing or is its right child pointer going to be</p>



<p>changing well you know when you originally looked at that 32 and you&#8217;re about to delete it you could</p>



<p>tell that it had that it had one child based on its left pointer and right pointer one of them</p>



<p>pointer one of them was null and one of them was not so whichever one of them was null that tells</p>



<p>you the direction that the grandparent should be pointing so in this case the 32 had a left child</p>



<p>pointer that was not null and a right child pointer that was null because there was no right child</p>



<p>so that&#8217;s why we told the grandparent that its left child pointer is now the 23.</p>



<p>and that&#8217;s it for deleting a node that has one child okay so uh i&#8217;m going to go ahead and delete</p>



<p>one more time and we&#8217;re going to do the deletion of a node let me let me write down you know deleted</p>



<p>a node one child yay we did it you guys um okay i&#8217;m gonna put that there too just for my notes</p>



<p>so this is going to be the hardest uh part we&#8217;re going to try to delete a node that has two</p>



<p>children maybe i&#8217;m first going to delete the uh the 35 nodes since that&#8217;s kind of where we&#8217;re</p>



<p>node since that&#8217;s kind of where we&#8217;re hanging out lately and then we&#8217;ll delete the hardest node of</p>



<p>all the 41 nodes so the first thing we need to know before we can get ready for deletion is</p>



<p>the in order traversal sequence of the data in this tree if you&#8217;re watching this video as soon</p>



<p>as i published it then i i don&#8217;t have videos up yet on traversal i&#8217;m going to upload those soon</p>



<p>then you can just check out one of my traversal videos.</p>



<p>But long story short,</p>



<p>in order traversal just means produce a sorted list,</p>



<p>an ascending list or a non-decreasing list</p>



<p>based off the data that&#8217;s inside of the tree.</p>



<p>So, you know, if I put this down here,</p>



<p>I can just say, you know, looking visually</p>



<p>from left to right, this is why I draw my trees in this way.</p>



<p>I see a six and then a nine and then an 11</p>



<p>and then a 16 and then a 19 and then a 23</p>



<p>and then a 29, no, no, no, a 26, and then a 29, and then a 32, 35, 38, 41, 43, 48, 52, 59, 67,</p>



<p>73, and 79. Let me just double check that I&#8217;ve done this correctly. The numbers seem to be</p>



<p>to be increasing or at least not decreasing.</p>



<p>Let me just double check.</p>



<p>Okay, how many do I have?</p>



<p>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19.</p>



<p>I already got lost.</p>



<p>I think it&#8217;s 19.</p>



<p>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19.</p>



<p>Okay, did it right.</p>



<p>list, an ascending list of the original data that was inside of the tree. And now we need to look</p>



<p>at a concept called in order successor. Successor comes after, predecessor comes before. Think of</p>



<p>like a king and a prince, right? The prince is the successor to the king. Eventually one day when</p>



<p>the king grows very old and becomes grandpa king and the prince grows up and becomes the regular</p>



<p>king, then you would look at the prince king and you would say, who was your predecessor? Well,</p>



<p>grandpa king right so whoever comes before his predecessor whoever comes after is the successor</p>



<p>so we want the in order successor of the node that we wish to delete so I can&#8217;t remember what</p>



<p>I said originally but let&#8217;s just say we&#8217;re going to delete the 35 node I should have written it</p>



<p>down let&#8217;s delete the 35 first we have to find the 35 itself to make sure it exists in the tree</p>



<p>so I&#8217;m going to look at the 41 I&#8217;m going to go left to the 16 I&#8217;m going to go right to the 35</p>



<p>We found it in O time in the worst case.</p>



<p>So this is obviously not going to be the fastest operation, but you know, all the ops are kind</p>



<p>of the same speed in a perfectly balanced binary search tree, not empirically, but in</p>



<p>terms of time complexity.</p>



<p>So we found the 35, we identified that it has two children.</p>



<p>So then what we have to do is find the in order successor.</p>



<p>What is the in order successor of the 35 node?</p>



<p>list 35 here and it appears to be 38 and that actually makes sense because since the data in</p>



<p>the tree is going to look sorted if you sweep your eyes from left to right assuming you drew</p>



<p>the diagram well you&#8217;re really just looking for the the node that is as close as possible</p>



<p>to the node you wish to delete but happens to be to the right of it there are some tutorials out</p>



<p>there that use the in order predecessor so that would mean the 32 would be the one you select</p>



<p>I like to do successor.</p>



<p>So first we find the 35,</p>



<p>then we find it&#8217;s in order successor.</p>



<p>We&#8217;ll do another delete maybe next of the 16 node</p>



<p>because that&#8217;ll be a little more difficult.</p>



<p>Once we find the in order successor,</p>



<p>we&#8217;re actually just gonna copy the data up into the tree.</p>



<p>So I&#8217;m gonna, sorry, up into the node we want to delete.</p>



<p>So that means I&#8217;m gonna take this 35</p>



<p>and it no longer has 35 as its value.</p>



<p>as its value. Instead, we&#8217;re going to steal the value of its in order successor. So 35, sorry,</p>



<p>38 up here. So now we have two 38s in the tree. That&#8217;s bad. We need to recursively delete the 38</p>



<p>node. It&#8217;s not really a recursive delete. It&#8217;s more like you&#8217;re inside the remove function or</p>



<p>the delete function or whatever you chose to call it. It&#8217;s usually remove. And after you&#8217;ve copied</p>



<p>of the in order successor to the node you actually wanted to delete then you call delete or remove</p>



<p>again on the the in order successor you probably want to use a pointer to that node or have some</p>



<p>sort of a way to reference that node without telling the tree to start deleting from the top</p>



<p>again because if we say if we just call tree.remove with the number 38 it&#8217;s going to actually find the</p>



<p>38 on top and that&#8217;s going to be no good because then if you&#8217;ve written your code correctly</p>



<p>uh at least after that point then it&#8217;s going to find the 38 and copy its value up</p>



<p>and then it&#8217;s going to happen all over again we&#8217;re going to just be stuck in an infinite loop</p>



<p>um so instead you want to have like a pointer to this node or a reference to this node</p>



<p>and then call a removal function or a delete function that can receive just like you know</p>



<p>a reference or pointer directly to that node and then if you notice the number 38 node</p>



<p>So there&#8217;s actually a guarantee that when you find the in-order successor, it will only have zero or one children.</p>



<p>It&#8217;s absolutely impossible, unless your tree is super messed up in some way, that the node would have two children.</p>



<p>Because if it did, then you have not gone far enough to the left towards the node you&#8217;re trying to delete.</p>



<p>Remember we said we need to find the node that is as close as possible to the node that we want to delete, but just like on the right side.</p>



<p>the 38 had a left child then we would actually want to follow the left child we wouldn&#8217;t stop at</p>



<p>the 38 node so it&#8217;s impossible for the node to have two children which means it&#8217;s going to end</p>



<p>up being an easy deletion so the first thing we do is we&#8217;re we&#8217;re saying let&#8217;s delete a node with</p>



<p>two children that&#8217;s the 35 we find it&#8217;s in order successor we copy its value up and then we call</p>



<p>delete again or remove again on this in order successor which is guaranteed to just be an easy</p>



<p>leaf removal or a node with one child removal where we just like you know promote its child up</p>



<p>and that&#8217;s it so let me uh let me duplicate this real fast and uh let me say also that everything</p>



<p>we just did was basically all it&#8217;s just going to be o of h because it&#8217;s going to be o of h to go</p>



<p>find the node in the worst case and then o of h to find its in order successor uh some fraction of</p>



<p>each you know o of h fraction o of h fraction but when you just combine them it&#8217;s just going to be</p>



<p>It&#8217;s just going to be O or log time if it&#8217;s a perfectly balanced tree.</p>



<p>And then once we find the in order successor and the node we want it to delete, it&#8217;s just</p>



<p>a matter of like just copying data and maybe doing the second delete.</p>



<p>So, you know, the second delete itself would just be like another O or log time.</p>



<p>So you probably know at this point that if you have two times log of N, it&#8217;s just going</p>



<p>to cancel out to log of N if we&#8217;re talking about big O time complexity.</p>



<p>time complexity. Anyway, so I&#8217;m going to duplicate this one more time and then revert everything</p>



<p>to scratch to scratch here or to the very beginning again. So we can delete something</p>



<p>that&#8217;s a little bit more difficult. Whoops, that&#8217;s bad. Can I get this? Nope. Can I get</p>



<p>that? Yes. Okay. So let&#8217;s delete that 16 node. So we can look at how you might find the in</p>



<p>order successor in a program because you don&#8217;t want to like traverse the whole entire tree and</p>



<p>produce a giant list and then scan the list and then like find the successor and then once you</p>



<p>know the number go search for the for the node that&#8217;s like going to be way too slow the tree</p>



<p>should be way faster than that so instead this is kind of how you do it let&#8217;s search for the 16 first</p>



<p>so we do like 41 16 belongs on the left side we found the 16 now we have to find the 16s in order</p>



<p>successor the one that comes after you can tell just by eyeballing it that it&#8217;s going to be the</p>



<p>eyeballing it that it&#8217;s going to be the number 19, right? But how do we find that number in the code</p>



<p>to make it a little bit faster? So again, 16 and 19, they&#8217;re just paired up right there.</p>



<p>Well, first you just take a hop to the right. So you look at the right child, if it exists.</p>



<p>If it doesn&#8217;t, then you have not tried to delete a node with two children. It was definitely a</p>



<p>node with the one child at most. So we take a hop to the right to find its right child.</p>



<p>as far down as you can possibly go until you reach a dead end.</p>



<p>So that means I&#8217;m taking a hop to the right and then I&#8217;m just going to go.</p>



<p>Maybe I&#8217;ll do like another color here.</p>



<p>I&#8217;ll go left child pointer, left child pointer, left child pointer,</p>



<p>as far down as I can possibly go. And that is the successor.</p>



<p>Notice how that&#8217;s the 19. Again,</p>



<p>if the 19 had a child on its left side,</p>



<p>we would have to follow it down further,</p>



<p>which means it&#8217;s guaranteed that you will stop at a node that has no left child.</p>



<p>no left child if it had a right child same situation it&#8217;s still going to be the in order</p>



<p>successor that just but that just means when we call a remove a second time on that node it&#8217;s</p>



<p>going to be a leaf that gets removed and not a node with one child so it&#8217;s just pretty easy let</p>



<p>me uh let me say that now that we&#8217;ve found the in order successor we&#8217;re just going to copy the value</p>



<p>so i&#8217;m going to do maybe i&#8217;ll put this in orange so this 16 is no longer in that particular node</p>



<p>no longer in that particular node we&#8217;re not even deleting that node we&#8217;re just stealing a value</p>



<p>from a different node we&#8217;re going to steal the 19 value from the node which is the in order successor</p>



<p>and now that we&#8217;ve done that we&#8217;ll use our reference to the 19 node to call remove on it</p>



<p>specifically so when we call remove or delete it&#8217;s basically going to say all right what sort</p>



<p>of node is this um it&#8217;s not even going to have to search for the node because you gave a point</p>



<p>you gave a point to the node or a reference to the node it&#8217;s going to go oh this is a leaf node</p>



<p>that&#8217;s easy i just tell the 23 that it has no left child anymore and then i just actually</p>



<p>deallocate the 19 node or if it&#8217;s a smart pointer let it die on its own anyway let&#8217;s do something a</p>



<p>little bit more difficult now so i&#8217;m going to duplicate this and try to revert all this stuff</p>



<p>Okay, okay.</p>



<p>Let&#8217;s delete the root node, the hardest node of all, the 41.</p>



<p>Okay, so if we want to delete the 41 node, I&#8217;m just going to put 41 here so I don&#8217;t forget.</p>



<p>First, we search for 41.</p>



<p>In the worst case, you know, it would have been O of H, but we were lucky.</p>



<p>We just found it right away.</p>



<p>Now we have to find the in-order successor for the 41.</p>



<p>So again, take a hop to the right and then follow left child pointers as far down as you can possibly go.</p>



<p>go so we&#8217;ll look at the 48 here and then we&#8217;ll look at the 43 now we&#8217;ve hit a</p>



<p>dead end and we know that the in-order successor for the 41 is 43 and that</p>



<p>makes sense because they&#8217;re paired up here in this sorted list at the bottom</p>



<p>so then the next thing that we do is we just copy the data you know we steal the</p>



<p>data from the 43 so I&#8217;m gonna cross out this 41 here and it&#8217;s gonna end up</p>



<p>and then we call delete a second time or remove a second time on the actual 43 which is another</p>



<p>easy removal because it could not possibly have two children it&#8217;s only going to have zero or one</p>



<p>children and well that&#8217;s pretty much it it&#8217;s just going to be just so fast and easy so that means</p>



<p>the 43 is gone when we&#8217;re finished here if you look at all the slides in this video you&#8217;ll notice</p>



<p>notice that the data is still ordered correctly so we do have a valid binary search tree even after</p>



<p>we kind of do this weird data stealing let me see if i can find something that would have had one</p>



<p>child so i want to look through the whole tree and see if i can find a node that has one child</p>



<p>that would make a good in order successor and if i can&#8217;t find one i&#8217;m just going to manufacture</p>



<p>one real fast let&#8217;s see um who has a right child only no one has a right child only that sucks</p>



<p>child only that sucks all right uh let&#8217;s say we want to delete the root node again</p>



<p>and i think last time we just said it was the 43 how about we uh that&#8217;s boring let&#8217;s delete the 59</p>



<p>okay so i&#8217;m going to uh write 59 up here so i don&#8217;t forget and then we&#8217;re going to add another</p>



<p>node real fast so that the 50 uh sorry the 67 has a right child why am i doing this because the 67</p>



<p>order successor of the 59 node. So I&#8217;m just going to draw like another line real fast like that.</p>



<p>And I&#8217;m going to update some number. Let me just say 70 is going to be the number in that node,</p>



<p>which is double check that it&#8217;s increasing 59, 67, 70. Okay. So we want to delete 79,</p>



<p>sorry, 59. The first thing we do is we go find the 59. So I&#8217;m going to</p>



<p>take off my line tool. Okay. So we&#8217;re going to go to the root 59 belongs on the right side.</p>



<p>59 belongs on the right side so we find the 59 there it is now we&#8217;re looking for the in-order</p>



<p>successor we go to the right side and then we follow all left child pointers until we hit a</p>



<p>dead end left child pointer dead end already because i mean there is a right child but we&#8217;re</p>



<p>supposed to be going down left child pointers there is no left child pointer so we&#8217;ve hit a</p>



<p>dead end so that means the 67 is the in-order successor of the 59 which means we&#8217;re going to</p>



<p>67 data and put it where the 59 data was. So again, we&#8217;re not really deleting the node that</p>



<p>had two children. We&#8217;re going to eventually delete the node that had one child, the successor.</p>



<p>But 67 is the number that&#8217;s going to be there. And then we call delete on this 67. And what&#8217;s</p>



<p>going to end up happening is our removal function identifies that that 67 had one child. And so what</p>



<p>one child which is the 70 node just one level higher where the 67 was so that means the uh</p>



<p>the 67 is just gone we do actually delete that and then the 70 node is going to be the new</p>



<p>left child of the 73 node notice how the data still makes sense okay i think that&#8217;s all i&#8217;ve</p>



<p>log time operation just one more time log time if the tree is perfectly balanced it&#8217;s a little bit</p>



<p>closer to linear time as the tree becomes more imbalanced if this was a self-balancing tree then</p>



<p>you know this would be like log time in terms of worst case scenario in general we&#8217;ll say that this</p>



<p>is still on average if we had just totally random data and totally random deletions on average this</p>



<p>would be you know a log time operation even if we do log down to find the node and then another</p>



<p>uh down to find the node and then another log to find the successor that&#8217;s still not going to be</p>



<p>you know worse than log or o of h in general okay that&#8217;s all i&#8217;ve got for you thank you so</p>



<p>much for watching this video i hope you learned a little bit of stuff and i hope you had a little</p>



<p>bit of fun i need to see if someone is selling pi at this hour going on a searching thing</p>



<p>Hey everybody!</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor,</p>



<p>could you please subscribe and follow this channel or these videos</p>



<p>or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos</p>



<p>and grow this community.</p>



<p>So we&#8217;ll be able to do more videos, longer videos, better videos,</p>



<p>videos or just I&#8217;ll be able to keep making videos in general so please do do</p>



<p>me a kindness and and subscribe you know sometimes I&#8217;m sleeping in the middle of</p>



<p>the night and I just wake up because I know somebody subscribed or followed it</p>



<p>just wakes me up and I get filled with joy that&#8217;s exactly what happens every</p>



<p>single time so you could do it as a nice favor to me or you could you control me</p>



<p>if you want to just wake me up in the middle of night just subscribe and then</p>



<p>I&#8217;ll just wake up I promise that&#8217;s what will happen also if you look at the</p>



<p>you look at the middle of the screen right now you should see a QR code which you can scan</p>



<p>in order to go to the website which I think is also named somewhere at the bottom of this video</p>



<p>and it&#8217;ll take you to my main website where you can just kind of like see all the videos I published</p>



<p>and the services and tutorials and things that I offer and all that good stuff and</p>



<p>if you have a suggestion for clarifications or errata or just future videos that you want to</p>



<p>just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also</p>



<p>wake up for those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like</p>



<p>it would really it really mean the world to me i would really appreciate it so</p>



<p>again thank you so much for watching this video and um enjoy the cool music</p>



<p>as as i fade into the darkness which is coming for us all</p>



<p>Thank you.</p>



<p>Hello there.</p>



<p>Let&#8217;s talk about.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-removals-delete-nodes-with-0-1-or-2-children/">Binary Search Tree Removals &#8211; Delete Nodes with 0, 1, or 2 Children</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/binary-search-tree-removals-delete-nodes-with-0-1-or-2-children/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Search in a Binary Search Tree (BST) &#8211; Step by Step Explanation with Examples</title>
		<link>https://www.NeuralLantern.com/how-to-search-in-a-binary-search-tree-bst-step-by-step-explanation-with-examples/</link>
					<comments>https://www.NeuralLantern.com/how-to-search-in-a-binary-search-tree-bst-step-by-step-explanation-with-examples/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sat, 02 May 2026 23:54:59 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree tutorial]]></category>
		<category><![CDATA[binary tree search]]></category>
		<category><![CDATA[BST explained]]></category>
		<category><![CDATA[BST search]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[data structures and algorithms]]></category>
		<category><![CDATA[log n time]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[search in BST]]></category>
		<category><![CDATA[tree traversal]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=336</guid>

					<description><![CDATA[<p>Learn how to search in a Binary Search Tree. We demonstrate searching for existing and non-existing values, explain why BST search is O(log n) on average, and show how poor data ordering can turn your tree into a slow linear structure similar to a linked list. Includes discussion of tree height and balanced vs unbalanced BSTs.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-search-in-a-binary-search-tree-bst-step-by-step-explanation-with-examples/">How to Search in a Binary Search Tree (BST) &#8211; Step by Step Explanation with Examples</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How to Search in a Binary Search Tree (BST) - Step by Step Explanation with Examples" width="1380" height="776" src="https://www.youtube.com/embed/FCz9IbLywI4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>In this video we walk through how to perform searches in a Binary Search Tree. Starting with a perfectly balanced BST, we cover the search process step by step, including finding existing nodes like 73 and determining that numbers like 44 do not exist in the tree.</p>



<p>We discuss time complexity for searches in BSTs &#8211; O(log n) on average for balanced trees and O(n) in the worst case when the tree becomes skewed like a linked list due to sorted or bad data. Learn why each comparison eliminates half the remaining data and how height affects performance.</p>



<p>Perfect for students learning data structures and algorithms. If you&#8217;re studying BSTs, this clear explanation will help you understand searching, insertion paths, and why self-balancing trees matter.</p>



<p>Thanks for watching!</p>



<p>00:00 Introduction to BST Search<br>00:31 BST Not Self-Balancing<br>00:40 Average Case Log Time<br>00:53 Linear Time in Worst Case<br>01:13 How BST Search Works<br>01:18 Search Path Example<br>02:08 Searching for Existing Node<br>02:35 Searching for Non-Existent Node<br>03:19 Tree Size and Height<br>03:30 Time Complexity O(h)<br>05:40 Bad Data Example<br>08:23 Skewed Tree Like Linked List<br>09:53 Linear Time in Worst Case<br>11:58 Why Log Time<br>12:36 Halving the Search Space<br>14:14 O(log n) Summary<br>14:28 Conclusion</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>hey there let&#8217;s perform searches in a binary search tree</p>



<p>okay if you watch my previous videos you know how to define a binary search tree by now</p>



<p>you know some terminology you know how to construct a tree and so now let&#8217;s just take</p>



<p>a tree that&#8217;s already been constructed and let&#8217;s search through it first thing i want to say is</p>



<p>first thing I want to say is this is a binary search tree this is not a self</p>



<p>balancing tree so in the future this tree could get lopsided and messed up</p>



<p>depending on what kind of data we add we can always expect that binary search</p>



<p>trees have a search time or an insert time or removal time of log log base 2</p>



<p>of n on average assuming that the data is random or in the worst possible case</p>



<p>scenario linear time so these could get slower right now you can see this tree</p>



<p>Right now you can see this tree is perfectly balanced.</p>



<p>So if we say that our tree is currently perfectly balanced and it&#8217;s always going to be perfectly balanced,</p>



<p>which is a fantasy, but let&#8217;s just say that it is,</p>



<p>then we could just say it&#8217;s a log tree.</p>



<p>It&#8217;s going to take log time to search through.</p>



<p>So how do we perform searches?</p>



<p>Again, if you saw my previous videos, you should know that it&#8217;s really easy to find out where a node belongs.</p>



<p>Like for example, if I was going to add the number 14,</p>



<p>I would first look at the root node and I&#8217;d say, okay, the root node is occupied.</p>



<p>and I&#8217;d say, okay, the root node is occupied.</p>



<p>And so where would 14 belong?</p>



<p>Well, it would belong on the left of 37</p>



<p>because it&#8217;s less than 37.</p>



<p>It would belong on the left of 16</p>



<p>because it&#8217;s less than 16.</p>



<p>It would belong on the right of 9</p>



<p>because it&#8217;s greater than 9.</p>



<p>It would belong on the right of 11</p>



<p>because it&#8217;s greater than 11.</p>



<p>And so the 14 node that we just wanted to add,</p>



<p>is that what I just said, 14?</p>



<p>Would end up going there.</p>



<p>So when you&#8217;re searching through a binary search tree,</p>



<p>you really just have to go find</p>



<p>have to go find where the node would belong as if you&#8217;re performing insert or you could think of it</p>



<p>the other way around like insert is really thinking of a search first but basically we&#8217;re just going</p>



<p>to start by saying you know pick a number and we&#8217;ll see if it exists so uh let&#8217;s pick the number</p>



<p>67 or actually let&#8217;s pick the number 73 just to see if it exists in the tree so 73 i&#8217;m going to</p>



<p>do like you know seven three with like a question mark we check the root node 73 belongs on the</p>



<p>side we look at the 59 it belongs on the right side and we found our 73 so 73 exists in the tree</p>



<p>and it only took us three examinations only three examinations let&#8217;s look for a number that doesn&#8217;t</p>



<p>actually exist in the tree so maybe oh my thing is freezing what&#8217;s going on okay so maybe uh let&#8217;s</p>



<p>The 37 here, 44 belongs on the right of 37.</p>



<p>We look at the 59, it belongs on the left.</p>



<p>We look at the 48, it belongs on the left.</p>



<p>We look at the 43, it belongs on the right.</p>



<p>The 44 would have been there, but it&#8217;s not because that right child pointer off the 43</p>



<p>is null.</p>



<p>So we only had to really examine one, two, three, four nodes in order to determine that</p>



<p>our number 44 didn&#8217;t exist in the tree.</p>



<p>Notice how we&#8217;re not doing a lot of examinations compared to the total size of the tree.</p>



<p>compared to the total size of the tree.</p>



<p>So let me just write this up here.</p>



<p>How many nodes do we have?</p>



<p>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15.</p>



<p>We got 15 nodes up here.</p>



<p>Someone say N is equal to 15.</p>



<p>And what&#8217;s the height of the tree?</p>



<p>Remember, the height of the tree is the number of nodes you must touch</p>



<p>as you make your way down towards the deepest node.</p>



<p>Or if you&#8217;ve already found the deepest node,</p>



<p>you take its depth and you just add 1, assuming that depths start at 0.</p>



<p>start at zero. So I&#8217;ll just say that the depth of the root node is zero and the 59 and the 16 are</p>



<p>one. And then that third row is two. And that last row is three. And then I just add one to the</p>



<p>deepest node that I can find, which is just going to have a depth of three. All of these on the</p>



<p>bottom row have a depth of three. So the height of this tree is actually four, because we would</p>



<p>so like 37 59 48 43 that&#8217;s four touches um or the or the depth of the deepest node plus one okay um</p>



<p>all trees all binary search trees whether they&#8217;re actually avl trees or regular binary search trees</p>



<p>or whether they&#8217;re balanced or imbalanced they&#8217;re always going to have a time complexity to search</p>



<p>through of o of h meaning in the worst case scenario you&#8217;ll have to touch h number of nodes</p>



<p>order to find a node by search query or to add a new node or even to delete a new node.</p>



<p>So how does that compare to this tree in reality?</p>



<p>Let me just open up a little calculator real fast.</p>



<p>I just want to show you.</p>



<p>So if we do log base two, because we have a binary search tree, not a trinary search</p>



<p>nodes 15 it tells us that it should take us no more than four examinations to find the node that</p>



<p>we&#8217;re looking for if the tree was perfectly balanced and if you if you if you notice that&#8217;s</p>



<p>exactly what the height is telling us here if the tree was more imbalanced the height would get</p>



<p>really bad compared to the number of nodes and it would no longer be considered a log tree it would</p>



<p>just be you know somewhere in between linear time and log time um let&#8217;s see what else can i show you</p>



<p>let&#8217;s do well we did that computation let&#8217;s do a search through the tree that</p>



<p>through a tree that&#8217;s actually really really bad let&#8217;s pretend that we have a</p>



<p>bunch of nodes here and you know I&#8217;ve got an old story that I love to tell</p>



<p>about this when like when my grandma was alive she was kind of bitter towards the</p>



<p>end you know I loved her but she used to call the cops on her neighbors for</p>



<p>gossip and at some point in time she got into a feud with her neighbor who was</p>



<p>with her neighbor who was also a bitter old lady.</p>



<p>You know, towards the end, it kind of happens sometimes.</p>



<p>It sucks, but it happened.</p>



<p>And I guess the neighbor didn&#8217;t like my grandma&#8217;s tree</p>



<p>that she had in her backyard.</p>



<p>So they fought over it, they argued over it,</p>



<p>and then one day my grandma said</p>



<p>she was looking out the backyard window</p>



<p>to yell at ducks who were jumping into her pool</p>



<p>because she just hated when the ducks went into her pool.</p>



<p>She was waiting for them to show up.</p>



<p>She wasn&#8217;t even looking at ducks.</p>



<p>even looking at ducks she was just waiting and she saw the other little old lady reach her arm over</p>



<p>the fence and spray my grandma&#8217;s tree with some sort of poison then my grandma&#8217;s tree died and uh</p>



<p>i guess you know my grandma never never got over it i always thought it was like a funny story it</p>



<p>was a little sad but um she poisoned my grandma&#8217;s tree so we can kind of do the same thing with the</p>



<p>binary search tree we can give bad data let me show you what happens here if i use this data set</p>



<p>search tree. So we&#8217;re going to add this node right here. It&#8217;s going to be the 14.</p>



<p>And then when we add the 19 node, I&#8217;m just going to duplicate it. The 19 is supposed to be on the</p>



<p>right side of 14 because it&#8217;s greater than 14. So I&#8217;m just going to like, you know, draw a 19 right</p>



<p>here and a little connecting line. Okay. Then when we add the 24, I&#8217;m going to duplicate this node</p>



<p>the 24 go belongs on the right side of the 14 and also belongs on the right side of the 19</p>



<p>because it&#8217;s greater than 19 so again we have a node that shows up on the right side let me</p>



<p>remember to actually fix the 19 so it looks like 24. then when we add the uh 29 it&#8217;s gonna end up</p>



<p>being the same thing right the 29 is gonna end up showing on the right the right the right it&#8217;s</p>



<p>If we have bad data, we can end up with a tree that kind of looks like a straight line.</p>



<p>And if you are watching this video from the future,</p>



<p>after I&#8217;ve posted all of my data structures videos that I have,</p>



<p>you might notice that this looks like another data structure.</p>



<p>If you&#8217;re watching this right away, I haven&#8217;t posted those videos just yet.</p>



<p>But just tilt your head to the right a little bit</p>



<p>and tell me if that looks like something that you recognize.</p>



<p>It looks like a linked list.</p>



<p>looks like a linked list just like a straight line or even i guess you could kind of say maybe an array</p>



<p>um just like a straight line of data there&#8217;s no uh you know there&#8217;s no splitting of the data</p>



<p>so we have the 29 and then the 35 and then uh maybe i&#8217;ll just do one more node only and i&#8217;ll</p>



<p>get rid of that 54 because that&#8217;s too many nodes so what happens is if you have you know bad data</p>



<p>tree doesn&#8217;t actually search or add insert or remove or anything like that in log time anymore</p>



<p>instead it operates in linear time just like a linked list would meaning we would have to scan</p>



<p>through every single node in the entire tree to be sure that some value did not exist well</p>



<p>not exactly but in the worst case scenario we&#8217;d have to scan through the whole entire tree</p>



<p>for example let&#8217;s just look at the the number of nodes real fast we&#8217;ll say the</p>



<p>number of nodes here is one two three four oh I put two 24s in there oh dearie</p>



<p>let me get that says 14 19 24 29 and then I guess I got to make that a 35 oh</p>



<p>okay and then there&#8217;s a 49 I guess I did add every single node okay so we added</p>



<p>so there&#8217;s like seven uh items in the tree so i&#8217;m going to say n is equal to seven the height also</p>



<p>is seven though so the height is seven notice how if we say that it&#8217;s always true that a binary</p>



<p>search tree has a time complexity in the worst case of o of h meaning you&#8217;d have to go down</p>



<p>in the worst case the number of levels that is equal to the whole entire height of the entire</p>



<p>tree that&#8217;s also the number of nodes in the tree which means uh if i wanted to add let&#8217;s say the</p>



<p>I don&#8217;t know, if you wanted to add the number 60,</p>



<p>60 would end up going down here.</p>



<p>And in order to find where 60 would go,</p>



<p>we&#8217;d have to look at the 14, that&#8217;s 1, 19, 24.</p>



<p>We&#8217;d have to look at all these nodes.</p>



<p>That is seven nodes.</p>



<p>We&#8217;d have to examine seven nodes</p>



<p>just to figure out where the 60 would go.</p>



<p>Or if we were searching for 60,</p>



<p>then we&#8217;d have to go down that far</p>



<p>to find out that 60 didn&#8217;t exist.</p>



<p>So this is nowhere near a log tree.</p>



<p>This is a linear tree, a linear time tree.</p>



<p>year time tree and just to drive the point further if we did log base two of the number of nodes in</p>



<p>this case seven notice how it&#8217;s telling us that we should if it was a log tree if it was perfectly</p>



<p>balanced or a self-balancing tree we should have to touch no more than three nodes in order to find</p>



<p>what we&#8217;re looking for to search through the tree or to insert a new node or even to delete a node</p>



<p>but that&#8217;s not the case here because the tree is really really slow compared to a perfectly balanced</p>



<p>slow compared to a perfectly balanced tree.</p>



<p>So we call this a linear tree.</p>



<p>It sucks.</p>



<p>You want to try to avoid that.</p>



<p>You don&#8217;t want your data to be poisoned.</p>



<p>On average, your trees won&#8217;t really look like this if you just have totally</p>



<p>random data, but if you think there&#8217;s a chance that your data might be skewed</p>



<p>in some way, it&#8217;s probably a good idea to upgrade to a self-balancing tree,</p>



<p>which we&#8217;re going to talk about later.</p>



<p>Okay.</p>



<p>What else can I tell you real fast?</p>



<p>So we talked about searching.</p>



<p>why are these trees considered log time? I mean, they&#8217;re really, really fast, but why?</p>



<p>Let&#8217;s just duplicate this slide here and I&#8217;ll move it down one level. I just want to kind of</p>



<p>show you why this ends up being a log time tree. Okay. So why, why is this a log time tree?</p>



<p>Suppose for the sake of argument, we&#8217;re searching for the number 52. So if we&#8217;re searching for the</p>



<p>node the root node and decide where would the 52 belong let me actually write that down so i don&#8217;t</p>



<p>forget 52 question mark where would the 52 belong it would belong on the right side of the 37 because</p>



<p>it&#8217;s greater than 37 right which means it&#8217;s actually impossible that the 52 would be in any</p>



<p>of these other nodes on the left side there&#8217;s no need to check them we&#8217;re not going to scan the</p>



<p>whole tree we&#8217;re just going to go left or right and ignore the whole other side of the tree</p>



<p>we just did is with one examination we eliminated half of the remaining data set or i guess of the</p>



<p>initial data set if we&#8217;re looking at the root node so then the next thing that we do is we just kind</p>



<p>of say okay it belongs on the right side so we look at the 59 node and we do the same thing we</p>



<p>say where would 52 be would it be on the left side or the right side of the 59 node it would be on</p>



<p>the left side which means we&#8217;re going to eliminate from consideration the entire right subtree of the</p>



<p>So again, we&#8217;re eliminating half of the remaining data set.</p>



<p>Then we kind of go down here and we look at the 48.</p>



<p>We do the same thing.</p>



<p>52 belongs on the right side.</p>



<p>So we eliminate half of the remaining data set, you know, and then eventually we do find</p>



<p>the 52 and then that&#8217;s it.</p>



<p>So if we&#8217;re eliminating half of the data set with every single, just one examination at</p>



<p>a time, that&#8217;s why it ends up being log base two.</p>



<p>getting twice as close to your destination at every step you took if you&#8217;re like in a car like</p>



<p>running maybe you&#8217;re on the moon or something then it would be a log time you know uh progress</p>



<p>towards your goal or eliminating half of the data set at every single step sometimes people see</p>



<p>for loops on exams and stuff when we talk about this um like for i equals zero uh i is less than</p>



<p>it would be like i times equals two.</p>



<p>So i&#8217;s jumping twice as far each time.</p>



<p>That&#8217;s the sort of thing that makes it log.</p>



<p>So I&#8217;m just going to write down log here real fast</p>



<p>to drive the point home a little bit more.</p>



<p>O of log base two of n.</p>



<p>Yeah, so I guess that&#8217;s all I wanted to tell you in this video.</p>



<p>Hopefully you feel like an expert in searching now.</p>



<p>If you want to see more searching videos,</p>



<p>leave a comment or something like that.</p>



<p>leave a comment or something like that. But yeah, thank you for watching. And I hope you</p>



<p>learned a little bit of stuff and had a little bit of fun. I&#8217;ll see you in the next video.</p>



<p>I&#8217;m going to go find a blueberry muffin.</p>



<p>Hey, everybody. Thanks for watching this video again from the bottom of my heart. I really</p>



<p>appreciate it. I do hope you did learn something and have some fun. If you could do me a please,</p>



<p>subscribe and follow this channel or these videos or whatever it is you do on the current social</p>



<p>media website that you&#8217;re looking at right now it would really mean the world to me and it&#8217;ll</p>



<p>help make more videos and grow this community so we&#8217;ll be able to do more videos longer videos</p>



<p>better videos or just i&#8217;ll be able to keep making videos in general so please do do me a kindness</p>



<p>and uh and subscribe you know sometimes i&#8217;m sleeping in the middle of the night and i just</p>



<p>It just wakes me up and I get filled with joy. That&#8217;s exactly what happens every single time</p>



<p>So you could do it as a nice favor to me or you could you control me if you want to just wake me up in the middle</p>



<p>And I just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen</p>



<p>Also, if you look at the middle of the screen right now</p>



<p>You should see a QR code which you can scan in order to go to the website</p>



<p>Which I think is also named somewhere at the bottom of this video and it&#8217;ll take you to my main website where you can just kind of like</p>



<p>and the services and tutorials and things that I offer and all that good stuff and</p>



<p>if you have a suggestion for</p>



<p>Clarifications or errata or just future videos that you want to see please leave a comment or if you just want to say hey</p>



<p>What&#8217;s up? What&#8217;s going on? You know, just send me a comment, whatever</p>



<p>I also wake up for those in the middle of the night. I get I wake up in a cold sweat. I&#8217;m like this</p>



<p>It would really it really mean the world to me. I would really appreciate it. So</p>



<p>So again, thank you so much for watching this video and enjoy the cool music as I fade into the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-search-in-a-binary-search-tree-bst-step-by-step-explanation-with-examples/">How to Search in a Binary Search Tree (BST) &#8211; Step by Step Explanation with Examples</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/how-to-search-in-a-binary-search-tree-bst-step-by-step-explanation-with-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Binary Search Tree Insertion Tutorial: Building a BST from Scratch Step by Step</title>
		<link>https://www.NeuralLantern.com/binary-search-tree-insertion-tutorial-building-a-bst-from-scratch-step-by-step/</link>
					<comments>https://www.NeuralLantern.com/binary-search-tree-insertion-tutorial-building-a-bst-from-scratch-step-by-step/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 27 Apr 2026 06:42:54 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree tutorial]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[BST insertion]]></category>
		<category><![CDATA[BST insertion step by step]]></category>
		<category><![CDATA[build BST from scratch]]></category>
		<category><![CDATA[coding interview prep]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[inorder traversal]]></category>
		<category><![CDATA[self balancing trees]]></category>
		<category><![CDATA[time complexity BST]]></category>
		<category><![CDATA[tree height]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=333</guid>

					<description><![CDATA[<p>Learn how to build a binary search tree (BST) by inserting numbers one by one. Follow the insertion process for the sequence 88, 21, 3, 6, 72, 34, 11, 1, 90, 65, 55, 17, 23, 9. See left/right decisions, pointer updates, inorder verification for sorted order, tree height calculation (6), and discussion of O(h) time complexity versus log n for balanced trees. Clear explanations without skipping steps.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-insertion-tutorial-building-a-bst-from-scratch-step-by-step/">Binary Search Tree Insertion Tutorial: Building a BST from Scratch Step by Step</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Binary Search Tree Insertion Tutorial: Building a BST from Scratch Step by Step" width="1380" height="776" src="https://www.youtube.com/embed/-vtcFOEkrEk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>In this hands-on tutorial, we build a binary search tree (BST) from scratch by inserting numbers one by one: 88, 21, 3, 6, 72, 34, 11, 1, 90, 65, 55, 17, 23, and 9. Watch as each node finds its correct position following BST rules, with clear explanations of left and right child decisions, parent pointers, and why the tree ends up looking a bit wonky but is still valid.</p>



<p>We cover the full insertion process, verify the tree is a proper BST by checking inorder traversal (sorted order), confirm it&#8217;s a connected acyclic rooted binary tree, and discuss tree height, time complexity (O(h) where h=6 for this tree), and why self-balancing trees matter for better performance.</p>



<p>Great practice for computer science students, programmers learning data structures, or anyone prepping for coding interviews. No fancy animations &#8211; just real step-by-step drawing and reasoning.</p>



<p>If you want more BST practice videos or specific insertion sequences, drop a comment below!</p>



<p>00:00 Introduction to BST Practice<br>00:35 Insertion Sequence Overview<br>00:59 Rules for Building BST<br>01:30 Insert 88 as Root<br>02:20 Continue building the tree from input data<br>13:04 Finish building the tree<br>14:56 Clean Up Diagram<br>15:24 Verify Inorder Traversal<br>16:48 Confirm Tree Properties<br>19:23 Tree Height and Time Complexity<br>22:01 Search Example for 55<br>23:09 Log Time vs Actual Height<br>24:21 Conclusion and Future Topics</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there! Let&#8217;s practice constructing a binary search tree from scratch.</p>



<p>In my previous video, we actually did this already, and in other previous videos we defined</p>



<p>what is a binary search tree and some terminology and stuff like that, but I thought it would</p>



<p>be nice to have two practice videos up. I&#8217;m willing to put more up if people want to make</p>



<p>comments about more trees that they want to see inserted. For now, I&#8217;m just going to say</p>



<p>we will add the following sequence of numbers. So this is a little diagram from the last time we</p>



<p>did this. Let me just, oh, I&#8217;m supposed to make that full screen so it can be bigger. Whoops.</p>



<p>Let me go ahead and add a new slide here. And then I&#8217;m going to do,</p>



<p>Okay, so we&#8217;re going to try to add the following sequence of numbers.</p>



<p>Like I said in my other video, don&#8217;t try to make the tree prettier.</p>



<p>Don&#8217;t get mad if a number looks like it&#8217;s too far to the left or something.</p>



<p>Just follow the normal rules of letting a node drop wherever it is supposed to drop</p>



<p>according to the rules of building a binary search tree.</p>



<p>So the first thing that I&#8217;m going to do is maybe draw a little arrow here.</p>



<p>I&#8217;m going to do like a pink arrow to indicate, you know,</p>



<p>You know, well, maybe I&#8217;ll do like a red one to indicate which number we&#8217;re actually trying to add at the moment.</p>



<p>So it&#8217;s going to be the 88 first.</p>



<p>Let&#8217;s see, we&#8217;ll put that right there.</p>



<p>And then now let&#8217;s say that the 88 is going to drop into our tree somewhere.</p>



<p>First question we have to ask ourselves is do we have a root node?</p>



<p>We don&#8217;t have a root node, which means the number we&#8217;re trying to add should be the root node.</p>



<p>And that&#8217;s it.</p>



<p>So I&#8217;m going to draw like a little circle here, a little node.</p>



<p>and I&#8217;m going to stick the number 88 inside of it we&#8217;re using integer t types</p>



<p>if you recall the last videos these nodes are supposed to be able to hold</p>



<p>almost any data type that you want they don&#8217;t have to be numbers but I&#8217;m just</p>



<p>going to use numbers for the sake of this example because it&#8217;s easier so I&#8217;m</p>



<p>going to say this is our root node it&#8217;s at the very top of the tree and we&#8217;re</p>



<p>done adding 88 and that&#8217;s it next step we&#8217;re going to add the 21 so I&#8217;m just</p>



<p>forward a little bit here and the 21 same question do we have a root node we currently do so that</p>



<p>means we can&#8217;t actually put the 21 there so we have to make a decision does the 21 belong on the</p>



<p>left or the right of the 88 the 21 is less than 88 which means it belongs on the left side so i&#8217;m</p>



<p>just going to duplicate this and try to make a pretty diagram by sort of splitting the difference</p>



<p>in terms of the empty space on the left between the edge of the screen and the existing root node</p>



<p>and make sure that it goes down, you know, a full rank, you know, at least the full height of a node,</p>



<p>maybe a little bit more, but you want to keep all same depth nodes on the same Y coordinate.</p>



<p>It&#8217;s just easier to debug your diagrams that way.</p>



<p>This one&#8217;s actually probably going to get messy. I might have to readjust this a few times.</p>



<p>I think I recalled these were, these might&#8217;ve been bad numbers. I can&#8217;t remember.</p>



<p>Okay. So the 21 is going to be the left child of the 88 because it belongs on the left side.</p>



<p>So I&#8217;m just going to do my little connecting line here.</p>



<p>connecting line here now 21 has a parent of 88 and 88 has a left child of 21 and we&#8217;re done adding</p>



<p>the 21 so i&#8217;m going to move the arrow to the three we&#8217;re now trying to add the three node</p>



<p>again we look at the root node we say okay that&#8217;s occupied so we can&#8217;t use that does three belong on</p>



<p>the left or the right of the 88 well it&#8217;s less than 88 so it belongs on the left the left child</p>



<p>again, does the three belong on the left or the right of the 21? It belongs on the left</p>



<p>because it&#8217;s less than 21 and the left child of 21 is currently doesn&#8217;t exist. It&#8217;s null.</p>



<p>So that means the three is going to be the new left child of the 21 node. Maybe just put it</p>



<p>like right there, put the three there. And then I&#8217;m going to do the connecting line in your code.</p>



<p>You can imagine that the left child pointer of the 21 node has now been set. So it&#8217;s pointing</p>



<p>been set so it&#8217;s pointing to the brand new node we just made for the three and then inside of the</p>



<p>three node its parent pointer is pointing to the 21 node okay so we&#8217;re done adding the three we</p>



<p>move on to the six same thing that we did before we look at the root node uh the six belongs on</p>



<p>the left so i&#8217;m gonna say go to the left the 21 node is it&#8217;s there it&#8217;s occupied so we have to</p>



<p>left of 21 because it&#8217;s less than 21 we go down to the left then we look at the three that&#8217;s also</p>



<p>occupied does the six belong on the left or right of three it belongs on the right side of three</p>



<p>because it&#8217;s greater than three so that means the sixth node is going to be the right child</p>



<p>of three again try to split the difference these diagrams get ugly fast i really</p>



<p>i don&#8217;t i don&#8217;t want to rearrange the topology but i&#8217;m probably gonna have to</p>



<p>I think I&#8217;m like crashing out here.</p>



<p>Oh, no.</p>



<p>Okay.</p>



<p>Nope.</p>



<p>Okay.</p>



<p>Let me try one more time.</p>



<p>These lines are killing me.</p>



<p>Okay.</p>



<p>I&#8217;m just going to update the three to a six and leave a little gap on that line.</p>



<p>It&#8217;s fine.</p>



<p>Now we&#8217;re ready to try to add the 72 node.</p>



<p>We have a little relief here because this is not like a smaller and smaller number that we&#8217;re dealing with.</p>



<p>So, well, we just look at the root node.</p>



<p>72 belongs on the left side so I&#8217;m going to hop to the left here we then look at</p>



<p>the 21 72 belongs on the right side because it&#8217;s greater than 21 so that</p>



<p>means 72 is going to be the right child of 21 so I&#8217;m just going to select this</p>



<p>make a duplicate try to keep the three and the six at the same you know y</p>



<p>coordinate because they&#8217;re on the same descendancy rank they&#8217;re at the same</p>



<p>you know generation whatever you want to call it so I&#8217;m going to put the 72 on</p>



<p>And then I&#8217;m going to do our connecting line, indicating that both nodes now have pointers that refer to each other.</p>



<p>Okay, we&#8217;re done adding the 72.</p>



<p>I&#8217;m going to move this to the right a little bit.</p>



<p>And then, oops, get rid of that little dot.</p>



<p>Now we&#8217;re ready to add the 34.</p>



<p>So the 34, we look at the 88 node occupied.</p>



<p>We go left.</p>



<p>We look at the 21 node.</p>



<p>34 belongs on the right side of 21.</p>



<p>of 21 so then we look at the 72 34 belongs on the left side of 72 so that means 34 is going to be</p>



<p>the left child of 72 so I&#8217;m going to select one of these nodes and duplicate it and say that</p>



<p>you have a left child of 72 now and it&#8217;s going to be the 34 node do my pointer connection real fast</p>



<p>I haven&#8217;t been duplicating the pages. Okay. So, uh, I guess that&#8217;s just for me.</p>



<p>We&#8217;ll move on to adding the 11 node.</p>



<p>So we add the 11 node by looking at the root node first.</p>



<p>11 belongs on the left side. We then look at the 21,</p>



<p>11 belongs on the left of 21. Go to the left here. We look at the three,</p>



<p>11 belongs on the right of the three. We go to the right,</p>



<p>11 belongs on the right of the six node.</p>



<p>This is definitely a gross graph at this point.</p>



<p>at this point. So I&#8217;m going to duplicate this node here and try to split the difference between</p>



<p>the six and the 21 in terms of like the free space. So I&#8217;m just going to drag this down a</p>



<p>little bit there and say that 11 goes as the new right child of the six node. So</p>



<p>just do that. This is a gross diagram. I might want to redraw this later.</p>



<p>Now we&#8217;re ready to try to add the one node.</p>



<p>the one again we look at the root node of the tree and it&#8217;s occupied so we can&#8217;t put it there</p>



<p>we go to the left we go to the left again and the one belongs on the left of the three nodes so we</p>



<p>have a little bit more room there so that&#8217;s good i&#8217;m gonna copy this node and make it the new left</p>



<p>child of the three i&#8217;m gonna like say that our one is right there and then i&#8217;m gonna do the connecting line</p>



<p>okay all right we&#8217;re done adding the one now I&#8217;m gonna add the 90 node oh this is</p>



<p>gonna be nice and easy because the 90 definitely belongs on the right side of</p>



<p>the 80 node whoops what happened okay sorry for making that noise I&#8217;m gonna</p>



<p>duplicate this node here and make it the right child of the 88 node so let&#8217;s see</p>



<p>kind of even there. So we&#8217;re going to put 90 right there. And then I&#8217;m going to do a connecting line</p>



<p>in blue. Now we&#8217;re done adding the 90.</p>



<p>So then we&#8217;re going to add the 65. 65 belongs on the left of the 88 node.</p>



<p>So we&#8217;re kind of in left territory now. It&#8217;s kind of sucky again.</p>



<p>And bounce down to the left. 66 belongs on the right side of the 21 node. So we look at the 72.</p>



<p>look at the 72 it belongs on the left of the 72 we go there it belongs on the right of the 34 so we</p>



<p>go right here as the new right child and the diagram kind of sucks at this point it&#8217;s a little</p>



<p>cramped but i&#8217;m going to try my best to split the difference between the 34 and the 32 visually to</p>



<p>make a nice easy to debug graph so maybe like somewhere around there put 66 then i&#8217;m going to</p>



<p>So the 66 is now the right child of 34.</p>



<p>Okay, next number that we&#8217;re going to add is my computer&#8217;s crashing.</p>



<p>Hello?</p>



<p>What happened?</p>



<p>There we go.</p>



<p>Okay.</p>



<p>So we&#8217;re ready to add the 55.</p>



<p>Oh, God.</p>



<p>Okay, let me see what&#8217;s going to happen here.</p>



<p>This is awful.</p>



<p>is awful i usually say you have to space these out enough so that none of these overlap but</p>



<p>they&#8217;re about to overlap okay we&#8217;ll do go to the left because 55 is less than 88 go to the right</p>



<p>because 55 is greater than 21 go to the left because it&#8217;s less than 72 go to the right because</p>



<p>it&#8217;s greater than 34 then go to the left again because it&#8217;s less than 66 i hate this i hate this</p>



<p>between 34 and 66, just to try to make it easier to debug.</p>



<p>This is almost, I&#8217;m almost stretched</p>



<p>to my mental limit right now.</p>



<p>So I&#8217;m gonna make the left child pointer here</p>



<p>and the new node we just added was 55.</p>



<p>Whoops, yeah, 55.</p>



<p>Okay, my God.</p>



<p>Let me just duplicate this one more time</p>



<p>and get rid of those pink arrows.</p>



<p>arrows let&#8217;s add the 17 next 17 right here um so once again we look at the root node it&#8217;s occupied</p>



<p>go to the left because it&#8217;s less than we look at the 21 we go left because it&#8217;s less than 21</p>



<p>we go to the right because it&#8217;s greater than three we look at the six we go to the right</p>



<p>because it&#8217;s greater than six we go to the right because it&#8217;s greater than 11.</p>



<p>So a super cramped diagram.</p>



<p>I&#8217;m in hell.</p>



<p>I&#8217;m just going to move this slightly to the right because this is just awful.</p>



<p>And I&#8217;m going to try to make sure again that same depth nodes are at the same Y coordinate.</p>



<p>Let me fix that number real fast before I forget.</p>



<p>And put it as a 17.</p>



<p>And then do my connecting line.</p>



<p>Like that.</p>



<p>Okay.</p>



<p>I&#8217;m losing it.</p>



<p>The, uh, whoops, the 23, where is this going to go?</p>



<p>Is it 23?</p>



<p>Um, Hmm.</p>



<p>Hmm.</p>



<p>Oh, well, it&#8217;s going to be like left child of the 34 probably.</p>



<p>Okay.</p>



<p>Let me just, uh, look at the root node.</p>



<p>Okay.</p>



<p>23 belongs on the left of that.</p>



<p>Look at the 21, 23 belongs on the right of that.</p>



<p>Cause it&#8217;s greater than 21.</p>



<p>Look at the 72.</p>



<p>It belongs on the left.</p>



<p>it belongs on the left look at the 34 belongs on the left and then that&#8217;s going to be the new left</p>



<p>child okay so I&#8217;m going to duplicate one of these nodes and it&#8217;s going to be the new left child of</p>



<p>the 34 node that is awful but I guess we barely have enough room let me change that to a 23 and</p>



<p>then I&#8217;ll add my connecting line okay and now we&#8217;re ready to add the final value in our tree</p>



<p>to be? It&#8217;s going to be like left child of 11 maybe. So we look at the root node. Whoops,</p>



<p>forgot to move that arrow. We look at the root node. We can&#8217;t put it there. Nine belongs on the</p>



<p>left side of the root. So we go like that. Nine belongs on the left side of the 21. Oh, did I just</p>



<p>guess something wrong? No, no, no. I think I&#8217;m okay. Go to the left side of that. We look at</p>



<p>right side of three we look at the six nine belongs on the right side of the six we look at</p>



<p>the eleven nine belongs on the left side of eleven because it&#8217;s less than eleven so I&#8217;m just going to</p>



<p>duplicate this and it&#8217;s going to end up being the left side whoops nope that&#8217;s wrong hang on a second</p>



<p>let me oh come on man let me get this down it&#8217;s going to be the left child of eleven not the left</p>



<p>there and the diagram is a little messed up maybe I should try to rearrange this in a second</p>



<p>it the topology is correct but it&#8217;s harder to debug because you can see that one of the right</p>



<p>descendants of the six node is actually physically on its left side and that just makes it extra hard</p>



<p>to debug but for now we&#8217;ll say that we&#8217;re done adding stuff into the tree so maybe I can kind</p>



<p>I&#8217;m not going to change the actual topology.</p>



<p>I&#8217;m just going to like, you know, redraw this in a slightly nicer way.</p>



<p>So I can probably take this whole subtree and move it over to the left a little bit to make it a little cleaner.</p>



<p>Which will give me some room to move this subtree a little bit over to the right.</p>



<p>Am I still wearing my microphone? Yeah.</p>



<p>And then it&#8217;s a little bit cleaner.</p>



<p>Then I just have to redraw this line.</p>



<p>Whoops.</p>



<p>oops yeah just have to redraw this line and now i think we&#8217;re following the rules that i talked</p>



<p>about before where a good diagram has all the left descendants physically on the left side of</p>



<p>a given node so let&#8217;s see the six has everything on the right and everything i think we&#8217;re okay</p>



<p>i&#8217;m going to duplicate this real fast and now let&#8217;s verify that our tree is actually correct</p>



<p>So I said this in the last video when we built a tree, but you basically want to take like the input data set here and sort it.</p>



<p>And whatever sorted list you end up with, that&#8217;s what you should see when you scan your eyes from left to right.</p>



<p>Again, this is another good argument for drawing the diagram in a really good way.</p>



<p>All left descendants are physically on the left. All right descendants are physically on the right.</p>



<p>So another way that I could do this, besides I don&#8217;t really want to sort this list right now,</p>



<p>Just scan from left to right and make sure that I see increasing numbers</p>



<p>Or if you&#8217;ve decided to make a tree that supports duplicates, make sure that you see non-decreasing numbers</p>



<p>But I&#8217;m looking for an ascending list</p>



<p>Okay, so I&#8217;m gonna just like do little hashes here</p>



<p>One is the lowest number. That&#8217;s good. Then if I go to the right just a little bit</p>



<p>I see a three go to the right a little bit. I see a six that&#8217;s still increasing then I see a nine and then I see an 11</p>



<p>still been increasing go to the right a little bit more it&#8217;s a 21 go to the right a little bit more</p>



<p>it&#8217;s a 23 then it&#8217;s a 34 then it&#8217;s a 55 then it&#8217;s a 66 then it&#8217;s a 72 so far everything&#8217;s been</p>



<p>increasing and then from 72 to 88 and from 88 to 90. so the ordering of the numbers are correct</p>



<p>let me just make sure i actually have a binary search tree by the definition of a bst first it</p>



<p>crazy lines going off in some direction or like different symbols this is a</p>



<p>connected graph meaning I could probably find well I definitely could find a path</p>



<p>from any node to any other node if I just you know trace the edges so can the</p>



<p>9 find its way to the 90 yeah if we just kind of like go you know up this way and</p>



<p>follow the edges up to the 88 and then back down to the 90 so every single node</p>



<p>could do that it could find every single other node on the graph which means this</p>



<p>every single other node on the graph which means this is a connected graph so that&#8217;s good the next</p>



<p>thing is now that we have a connected graph do we have a tree so check for cycles uh can any start</p>



<p>node find its way back to itself in a path that does not repeat edges i don&#8217;t see that anywhere</p>



<p>in the tree so i think we have a valid tree let me get rid of that real fast so for example uh</p>



<p>Could we find a path that goes away from the 9 node and then comes back without repeating any edges?</p>



<p>I cannot because as soon as we go out to the 11,</p>



<p>later on we would have to use that same edge to come back down to the 9 and that would be repeating an edge.</p>



<p>So we just kind of check that for every single node.</p>



<p>We can&#8217;t find a cycle anywhere in this entire graph.</p>



<p>So this is an acyclic graph.</p>



<p>Okay, that means it&#8217;s a tree.</p>



<p>Is this a rooted tree?</p>



<p>ancestor to all other nodes and it&#8217;s that 88 node that&#8217;s the root node of the</p>



<p>entire tree every single node in the tree can say that 88 is its greatest</p>



<p>ancestor there&#8217;s no you know same leveled nodes at the very very very top okay so</p>



<p>this is a rooted tree now is it a binary tree yeah we look at every single node</p>



<p>and we can see that none of the nodes have more than two children they&#8217;ve all</p>



<p>this is a binary tree. And then when we, you know, we verified the numbers a second ago,</p>



<p>that means this is a binary search tree. So it satisfies all the properties of a binary search</p>



<p>tree. It doesn&#8217;t look very good. It&#8217;s kind of wonky, but it is valid. Remember this,</p>



<p>you know, a binary search tree just by itself is not a self-balancing tree,</p>



<p>which means you, you, you need to like not inject your human feelings into the tree while you&#8217;re</p>



<p>building it and start rearranging it to make it prettier. It wouldn&#8217;t be a valid binary search</p>



<p>if you tried to add special rules when you were creating it.</p>



<p>I don&#8217;t know.</p>



<p>If you imagine that maybe you, the human,</p>



<p>were changing the input data,</p>



<p>then I guess that&#8217;s valid.</p>



<p>But don&#8217;t imagine that the tree</p>



<p>is changing the data as you add it.</p>



<p>Anyway, so how fast is this tree?</p>



<p>Remember we said in a previous video</p>



<p>that a perfect binary search tree,</p>



<p>meaning perfectly balanced on every single node,</p>



<p>would be a log time tree.</p>



<p>It would be really, really fast to add and search</p>



<p>to add and search and even remove but this tree is definitely lopsided so this</p>



<p>is not a log tree the time complexity of a binary search tree actually is not</p>



<p>really log because the tree could just grow in any direction so in the worst</p>



<p>case scenario if you add the worst possible data you&#8217;d end up with a linear</p>



<p>time tree self balancing trees will be log time trees because they always</p>



<p>rearrange themselves to make sure that they&#8217;re balanced to a certain extent but</p>



<p>But, you know, as a binary search tree scales, it could just get slower and slower and slower.</p>



<p>So we wouldn&#8217;t be able to say that BSTs, binary search trees in general are log time.</p>



<p>We could pull up a calculator though and we could say, well, you know, what&#8217;s the height of this particular tree?</p>



<p>Let me just look at the depths real fast here.</p>



<p>What&#8217;s the height of this tree?</p>



<p>So the root node has a depth of zero and then one and then two and then three and then four.</p>



<p>drawing your tree in a nice pretty way where all the ranks are the same physically.</p>



<p>We just take the deepest node and we add one to it and we say that&#8217;s the height.</p>



<p>So the height of this tree is six.</p>



<p>Another way of looking at it is if we wanted to touch one of the deepest nodes,</p>



<p>how many nodes would we have to touch as we travel down through the tree?</p>



<p>So how many nodes would we have to touch to find, you know, the nine or the 17 or the 55?</p>



<p>one node the 88 two and let&#8217;s go to the left three four five six we&#8217;d have to touch six nodes</p>



<p>to get to the deepest node so that&#8217;s why we&#8217;re saying that&#8217;s another way that we&#8217;re justifying</p>



<p>that we say the height is six so the height of this tree is six which means in the worst case</p>



<p>scenario if we needed to search this tree again we&#8217;ll talk about actually searching in another</p>



<p>video but for now i can just promise you that if we were going to search this tree we could do it</p>



<p>going to search this tree we could do it in at most six uh examinations so even though we have</p>



<p>a lot of nodes here how many nodes do we actually have let me just double check this we have n</p>



<p>is equal to one two three four five six seven eight nine ten eleven twelve thirteen fourteen</p>



<p>we have fourteen nodes but at most we&#8217;d have to examine six nodes because this is a binary search</p>



<p>tree so it&#8217;s a lot faster than scanning the whole tree in linear time but it could be a lot faster</p>



<p>It could be a lot faster if the tree was better balanced.</p>



<p>That&#8217;s a topic for another day.</p>



<p>So for example, if we wanted to search for the number 55, let&#8217;s say we were just going</p>



<p>to search for 55, you know, we&#8217;d look at the 88.</p>



<p>Basically searching is pretty much the same as adding a node.</p>



<p>You just kind of go find where the node would belong.</p>



<p>And then if it&#8217;s there, then you found it.</p>



<p>And if not, then it&#8217;s not in there.</p>



<p>55 belongs on the left of 88, belongs on the right of 21, it belongs on the left of 72.</p>



<p>belongs on the left of 72, belongs on the right of 34, belongs on the left of 66, and there we</p>



<p>found it. Notice how we only did one, two, three, four, five, six examinations. So I&#8217;m going to talk</p>



<p>about big O and time complexities in another video, but long story short, the time complexity</p>



<p>of this particular tree, or actually any binary search tree, is always going to be O of H, no</p>



<p>imbalanced or perfectly balanced O of H so in the worst case scenario since H is 6 we&#8217;re going to have to touch H or 6 nodes</p>



<p>To search or add something or whatever if the tree was perfect. It would look more like log time. Let&#8217;s pull up that calculator real fast</p>



<p>Where the heck is my calculator? I think I like got sidetracked</p>



<p>so if I pull up a calculator here</p>



<p>and I typed in</p>



<p>log base 2 it&#8217;s base 2 because we only allow two children per node at most log</p>



<p>base 2 of the number of nodes in the tree so log base 2 of 14 if we get the</p>



<p>answer to that it says 3.8 which means the calculator is telling us that in a</p>



<p>log time tree we should not have to examine more than four nodes in order to</p>



<p>search the tree or add a brand new node but this is not a log tree because it is</p>



<p>totally imbalanced it&#8217;s kind of wonky it&#8217;s not it&#8217;s not perfect so it&#8217;s telling us in a perfect</p>



<p>tree we&#8217;d have to touch four nodes only but we clearly know we might have to touch six nodes in</p>



<p>the worst case so that i&#8217;m just trying to bring to your attention that the more imbalanced the tree is</p>



<p>the further its uh performance drifts away from log time which is a great argument</p>



<p>I think this is pretty much everything I wanted to talk about today.</p>



<p>I&#8217;m going to take a break and like, you know, eat some cookies and stuff.</p>



<p>But in a future video, we&#8217;re going to talk about inserting.</p>



<p>No, we already just did that literally right now.</p>



<p>We&#8217;re going to talk about searching through the tree.</p>



<p>We&#8217;re going to talk about removing nodes from the tree.</p>



<p>We&#8217;re going to talk about linear trees.</p>



<p>We&#8217;re going to talk about all the time complexities.</p>



<p>And then eventually we&#8217;ll move on to self-balancing trees.</p>



<p>on to self-balancing trees. So I hope you had fun watching this video. I hope you learned a little</p>



<p>bit of stuff and I&#8217;ll see you at a later date in time. I&#8217;m outie. Patowdy. Note to self, edit out</p>



<p>Patowdy. Hey everybody, thanks for watching this video again from the bottom of my heart. I really</p>



<p>hope you did learn something and have some fun if you could do me a please a small little favor</p>



<p>could you please subscribe and follow this channel or these videos or whatever it is you do on the</p>



<p>current social media website that you&#8217;re looking at right now it would really mean the world to me</p>



<p>and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do more videos</p>



<p>longer videos better videos or just i&#8217;ll be able to keep making videos in general so please</p>



<p>and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up</p>



<p>because I know somebody subscribed or followed. It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time. So you could do it as a nice favor to me or you</p>



<p>could, you could troll me if you want to just wake me up in the middle of the night, just subscribe</p>



<p>and then I&#8217;ll, I&#8217;ll just wake up. I promise that&#8217;s what will happen. Also, uh, if you look at the</p>



<p>middle of the screen right now, you should see a QR code, which you can scan in order to go to the</p>



<p>we&#8217;re at the bottom of this video and it&#8217;ll take you to my main website where you can just kind of</p>



<p>like see all the videos i published and the services and tutorials and things that i offer</p>



<p>and all that good stuff and uh if you have a suggestion for uh uh clarifications or errata</p>



<p>or just future videos that you want to see please leave a comment or if you just want to say hey</p>



<p>what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also wake up for those in the</p>



<p>wake up in a cold sweat and i&#8217;m like it would really it really mean the world to me i would</p>



<p>really appreciate it so again thank you so much for watching this video and um enjoy the cool music</p>



<p>as as i fade into the darkness which is coming for us all</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-insertion-tutorial-building-a-bst-from-scratch-step-by-step/">Binary Search Tree Insertion Tutorial: Building a BST from Scratch Step by Step</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/binary-search-tree-insertion-tutorial-building-a-bst-from-scratch-step-by-step/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Building a Binary Search Tree &#8211; Insertion Tutorial</title>
		<link>https://www.NeuralLantern.com/building-a-binary-search-tree-insertion-tutorial/</link>
					<comments>https://www.NeuralLantern.com/building-a-binary-search-tree-insertion-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 12 Apr 2026 05:12:30 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree example]]></category>
		<category><![CDATA[binary search tree tutorial]]></category>
		<category><![CDATA[binary tree insertion]]></category>
		<category><![CDATA[BST depth]]></category>
		<category><![CDATA[BST from scratch]]></category>
		<category><![CDATA[BST height]]></category>
		<category><![CDATA[BST insertion]]></category>
		<category><![CDATA[build binary search tree]]></category>
		<category><![CDATA[computer science tutorial]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[data structures and algorithms]]></category>
		<category><![CDATA[in order traversal]]></category>
		<category><![CDATA[insert into binary search tree]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=330</guid>

					<description><![CDATA[<p>In this tutorial we build a binary search tree together by inserting the numbers 73, 98, 12, 45, 67, 10, 43, 11, 99, and 32 one by one. Starting from an empty tree, each number is placed according to binary search tree rules: smaller values go left, larger values go right. We let the nodes fall where they belong without any rearranging, resulting in a realistic (and slightly lopsided) BST. The video explains tree depth, height, and confirms the final structure maintains all BST properties with a properly sorted in-order traversal.</p>
<p>The post <a href="https://www.NeuralLantern.com/building-a-binary-search-tree-insertion-tutorial/">Building a Binary Search Tree &#8211; Insertion Tutorial</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Building a Binary Search Tree - Insertion Tutorial" width="1380" height="776" src="https://www.youtube.com/embed/iuuUaa4CxoU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>In this hands-on video we build a binary search tree by inserting numbers one by one: 73, 98, 12, 45, 67, 10, 43, 11, 99, and 32. Watch exactly how each node finds its place following BST rules with no rearranging allowed.</p>



<p>We discuss why the tree becomes lopsided, calculate its height, and verify the in-order traversal is sorted. Great practice for anyone learning binary search trees.</p>



<p>Next videos will cover searching and deleting nodes.</p>



<p>If you&#8217;re studying data structures, build along with me!</p>



<p>00:00 Introduction to Building a Binary Search Tree<br>00:14 Plan for Inserting Numbers<br>00:30 First Node Becomes Root<br>02:26 Begin inserting from data set<br>12:29 Final insertion from data set<br>13:26 Final Tree Overview<br>13:29 Tree is Lopsided<br>14:00 Drawing Depths and Levels<br>14:50 Calculating Tree Height<br>15:08 Verifying Sorted Order<br>16:00 Confirming BST Properties<br>16:48 Time Complexity and Height<br>18:59 No Self-Balancing<br>19:07 End of Video and Thanks</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>hey there let&#8217;s build a binary search tree together if you&#8217;ve seen my previous videos</p>



<p>you understand now how to define a binary search tree meaning what are the rules</p>



<p>that you have to like adhere to if you want your thing to be a binary search tree</p>



<p>also terminology we&#8217;re in previous videos so in this video we&#8217;re just going to take a bunch of</p>



<p>random numbers and we&#8217;re just going to start dropping them into our tree and see how the</p>



<p>tree builds itself out we have to build our tree in a specific way if it&#8217;s going to be valid we&#8217;re</p>



<p>uh valid we&#8217;re not going to rearrange our tree and try to make it super pretty this is going to be</p>



<p>like a real binary search tree it might not be pretty but it&#8217;ll be real let&#8217;s see if i can find</p>



<p>those numbers that i was going to set up okay so for this particular video i think i&#8217;m going to do</p>



<p>two videos i want to build a binary search tree using the following numbers they&#8217;re not special</p>



<p>not not perfect but what I mean to say when I say inserting these numbers is one by one we&#8217;ll look</p>



<p>at each number and we&#8217;ll drop it in the tree and we&#8217;ll see where it falls according to binary</p>



<p>search tree rules of insertion then we&#8217;ll just go to the next number and then the next and the next</p>



<p>when we&#8217;re done we should have a tree and if you follow along at home and you use the right rules</p>



<p>to build your tree then if we use the same sequence of numbers to build the tree we should</p>



<p>they won&#8217;t suddenly be different they&#8217;re deterministic okay so the first thing that</p>



<p>we should try to understand is uh when we want to insert a node the 73 node right here the first</p>



<p>thing we should ask ourselves is do we actually have a root node for our binary search tree yet</p>



<p>right now the answer is no this is just a blank tree there&#8217;s nothing in it which means that first</p>



<p>number is going to be the root node you might be tempted to say no that&#8217;s a sucky root node let&#8217;s</p>



<p>do something else well i don&#8217;t know i mean you just have to let the numbers fall where they&#8217;re</p>



<p>going to fall just because a number seems to suck as a root node doesn&#8217;t mean it&#8217;s not going to be</p>



<p>the root node if it&#8217;s the first thing you added it&#8217;s going to be the root node don&#8217;t try to change</p>



<p>it or you&#8217;re going to mess you&#8217;re going to end up with topology that doesn&#8217;t match whatever system</p>



<p>or person is trying to grade your work or evaluate your work so we have no root node that means the</p>



<p>node of the entire tree we&#8217;re now done with 73 i&#8217;m going to duplicate this slide real fast</p>



<p>and we&#8217;ll say now it&#8217;s time to try to add the 98 you know what i can i think i can do better than</p>



<p>that arrow i can make a nice cute arrow with this program i&#8217;m going to do this can i like yeah</p>



<p>hang on one more one more try nice okay so now let&#8217;s add the 98 node</p>



<p>the first thing we have to ask is do we have a root node uh yes we can&#8217;t actually put the 98 there</p>



<p>we now have to make a decision uh if you recall in my previous videos the lesser values go on the</p>



<p>left and the greater values go on the right uh in in these trees which we&#8217;re not going to support</p>



<p>duplicate values with if you wanted to support duplicate values you could do something like</p>



<p>less than or equal to would be on the left and greater than on the right there&#8217;s a bunch of</p>



<p>other ways you can do it but i&#8217;m just going to say no duplicate values in our trees so we look at the</p>



<p>So we look at the 73 node and we ask, you know, is that where our 98 is going to go?</p>



<p>It can&#8217;t go there because 73 exists.</p>



<p>Now we have to ask the question, does 98 belong on the left side or the right side of the 73?</p>



<p>Well, because 98 is greater than 73, it belongs on the right side, which means I&#8217;m going to duplicate this node over here.</p>



<p>And I&#8217;m going to try to draw this well, which means basically splitting the difference in terms of the empty space.</p>



<p>empty space and trying to keep the same rank as we go down one level of</p>



<p>descendancy or like one generation down at a time.</p>



<p>So the next time I go down a level,</p>



<p>let&#8217;s say I do a left child in the future,</p>



<p>it should be at the same level as the new node I just added.</p>



<p>So I did a duplicate and I forgot to change the number.</p>



<p>And then I&#8217;m going to do a line to connect the 73 and the 98.</p>



<p>98 so now the 73 has a right child which is 98 the 98 has a parent which is 73 and we&#8217;re done</p>



<p>adding the 98 we have to just move on to the next number okay so i&#8217;m going to move on to the 12</p>



<p>again we look at the root node it&#8217;s occupied we cannot put the 12 right there on the 73 we have</p>



<p>to make a decision do we go to the left or the right of the 73 12 is less than 73 so it belongs</p>



<p>is to jump to the left side. Notice how the left side there&#8217;s no child on the left that means that&#8217;s</p>



<p>where the new node is going to go so I&#8217;m just going to like select this duplicate it real fast</p>



<p>maybe stick it on the same vertical coordinate and then also try to split the difference on</p>



<p>the screen just to make it look pretty. I&#8217;m going to update that 98 so that it is now the 12.</p>



<p>child 12 and then we&#8217;re done adding the 12. Okay, no problem so far. We then are ready to try to</p>



<p>add the 45. Maybe I should squish this a little bit. Nope, that looks gross. No, it&#8217;s okay.</p>



<p>We&#8217;ll do that. We&#8217;re going to add the 45. Again, we look at the root node. It already exists,</p>



<p>so we can&#8217;t put the 45 there. Instead, we will just kind of decide does the 45 belong on the</p>



<p>Okay, well, belongs on the left because it&#8217;s less than 73.</p>



<p>So that means I&#8217;m now going to make a little decision.</p>



<p>I&#8217;m going to jump down to the left.</p>



<p>If you&#8217;re in some code, you&#8217;re following the left child pointer down.</p>



<p>But notice how the left child pointer or the left child, it already exists.</p>



<p>So we can&#8217;t actually put 45 right there.</p>



<p>We have to make another decision.</p>



<p>Does 45 belong on the left or the right of the 12?</p>



<p>Well, it&#8217;s greater than 12.</p>



<p>So it belongs on the right side of 12.</p>



<p>So I&#8217;m going to highlight this and duplicate it.</p>



<p>and duplicate it. I guess I&#8217;ll just do it that way. Then I&#8217;m going to update that number</p>



<p>with 45 and then I&#8217;m going to connect the 12 and the 45 with the line. So now 45 is the right child</p>



<p>of 12 and 12 is the parent of 45. It&#8217;s at this point that a lot of people start to get frustrated</p>



<p>with me and they say, well, how come, how come the 12 is like all the way to the left and the 45 is</p>



<p>45 is like didn&#8217;t become like you know a level higher because it kind of seems like it&#8217;s closer</p>



<p>to 73 shouldn&#8217;t the 12 be hanging off the left child of the 45 no no no no don&#8217;t rearrange the</p>



<p>nodes as you&#8217;re building the tree just let the numbers let the nodes fall wherever they&#8217;re</p>



<p>supposed to go another tip is if you&#8217;re building a tree that has other data types as as the t types</p>



<p>inside of the nodes as the template types inside of the nodes for example right now I&#8217;m just using</p>



<p>type is int, at least in my mind, if you wanted to put dinosaur objects in the tree, all you&#8217;d</p>



<p>have to do is make sure that your code for your dinosaur class for your dinosaur object</p>



<p>had its inequality operators implemented, you know, less than, greater than, and then the tree</p>



<p>would still know where to put all the objects. So you could make any kind of custom object you want</p>



<p>and they would all fall in their correct places in the tree as long as the operators actually</p>



<p>just as a side note. Okay, so now we&#8217;re ready to add the next item. So I&#8217;m going to erase this</p>



<p>stuff here, and I&#8217;m going to move the arrow from the 45 to the 67. So now we&#8217;re going to try to</p>



<p>add the 67. We look at the root node, it&#8217;s occupied. We should go to the left because 67</p>



<p>is less than 73. We look at the 12, that&#8217;s occupied. So we go left or right. We should go</p>



<p>to the right because 67 is greater than 12. So we look at the 45. Again, it&#8217;s occupied. There&#8217;s a</p>



<p>a node there so we have to make another decision do we go to the left or to the right well 67 is</p>



<p>greater than 45 so it goes on the right side so i&#8217;m going to duplicate this off to the right side</p>



<p>and down a rank and we&#8217;ll call that the right child of 45. let me update the number here</p>



<p>to 67 and i&#8217;ll connect that as the right child okay</p>



<p>Any questions? I&#8217;m just kidding. That was rude. Just know that my heart is with you if you&#8217;re</p>



<p>asking questions. Send me a comment in the comments. So now I&#8217;m going to move over to the 10 here.</p>



<p>Again, we look at the 67. The 10 belongs on the left. So we kind of go to the left.</p>



<p>We look at the 12. The 10 belongs on the left of the 12 because it&#8217;s less than 12.</p>



<p>available slot that&#8217;s an available child pointer so I&#8217;m going to say the 10 is going to be the</p>



<p>left child of the 12 node maybe I&#8217;ll stick it all the way over there let&#8217;s see is there anything</p>



<p>less than 10 in there nope okay so we&#8217;ll be good we have enough space on the screen</p>



<p>so change that to a 10 do the connecting line so the 10 is now the left child</p>



<p>whoops the left child of the 12 node and now we&#8217;re ready to add the next node</p>



<p>node. Okay. So now the 43 is the next one we want to add. One more time, we look at the 73 node,</p>



<p>the root node is occupied. So we have to go to the left because 43 is less. So oops, that&#8217;s a line.</p>



<p>So now we look at the 12 node is 43 greater than or less than the 12. It&#8217;s greater than so that</p>



<p>means we go down to the right. But the 45 is there. So we have to make another decision. 43 is less</p>



<p>43 is less than 45 so we go to the left that means this 43 is going to be the left child of 45.</p>



<p>And again don&#8217;t try to make the tree pretty or better just let the nodes fall wherever they&#8217;re</p>



<p>supposed to fall according to the rules of less than or greater than. So now we got the uh whoops</p>



<p>I forgot to change that to a 43. The 43 right there and we are now ready to add another node</p>



<p>So I&#8217;m going to like erase this stuff here and I want to move the arrow to the 11.</p>



<p>Now once again, we&#8217;re looking for the root node.</p>



<p>It&#8217;s already occupied.</p>



<p>We say that 11 is supposed to go on the left because it&#8217;s less than.</p>



<p>We look at the 12.</p>



<p>It&#8217;s occupied.</p>



<p>So we have to go to the left because 11 is less than 12.</p>



<p>We go to the 10 and that&#8217;s also occupied.</p>



<p>So we have to make another decision.</p>



<p>Is 11 greater than or less than 10?</p>



<p>It&#8217;s greater than.</p>



<p>why the 11 goes on the right side of the 10. So I&#8217;m going to duplicate this over here. Notice how</p>



<p>I&#8217;m trying to keep same ranked children or same depth children physically at the same level. It&#8217;s</p>



<p>a lot easier to debug your diagrams if you do things this way. Notice also, as I mentioned in</p>



<p>a previous video, that every left descendant of a node should be physically on the left side in my</p>



<p>diagram and every right descendant should be physically on the right side. That just makes</p>



<p>right side that just makes the diagram way easier to debug what do I mean by this look at 73&#8217;s left</p>



<p>descendants its left subtree they&#8217;re all physically on the left look at the 12 node all of its right</p>



<p>descendants or its right subtree they&#8217;re all physically on the right so you if you follow</p>



<p>that rule it&#8217;s just way easier to debug I think I forgot to update that number from 43 to 11 so</p>



<p>I&#8217;m going to do that now and we are ready to add the next number the 99 so I&#8217;m going to do this</p>



<p>So I&#8217;m going to do this. We&#8217;re looking at 99.</p>



<p>So first we start off by looking at the root node.</p>



<p>It&#8217;s 73, occupied. 99 belongs on the right side.</p>



<p>So now we bounce to the right side and we look at the 98.</p>



<p>Whoops, whoops, whoops. We look at the 98.</p>



<p>That&#8217;s occupied, so we make another decision.</p>



<p>The 99 belongs on the right side of 98. That slot is available.</p>



<p>So now we can say that the 99 node is supposed to be</p>



<p>a right child of 99.</p>



<p>Sorry, sorry.</p>



<p>The 99 is the right child of the 98 node.</p>



<p>I&#8217;m getting a little confused.</p>



<p>Okay, so I&#8217;m gonna do a little connecting line there.</p>



<p>And we&#8217;re ready to add the final value into our tree.</p>



<p>So I&#8217;m gonna do, let&#8217;s see.</p>



<p>Oh, oh, I accidentally erased the arrow.</p>



<p>Oh, there it is.</p>



<p>We can add the 32 next.</p>



<p>add the 32 next and if we look at the 73 it&#8217;s occupied 32 belongs on the left so then we just</p>



<p>kind of like follow down to the left here we look at the 12 32 belongs on the right of 12 so we</p>



<p>follow down to the right 32 belongs on the left of 45 so we follow down to the left 32 belongs on</p>



<p>the left of 43 and so we will make 32 the left child of the 43 node so I&#8217;m going to like select</p>



<p>this real fast we go down a full rank and I&#8217;m going to try to split the difference between 12</p>



<p>And I&#8217;m going to try to split the difference between 12 and 43 here just to make the diagram easier to debug.</p>



<p>Okay, so then I&#8217;m going to do…</p>



<p>It&#8217;s looking a little gross, but at least we&#8217;re finished.</p>



<p>I have to update that 11 to be the 32.</p>



<p>And now we&#8217;re done building our tree.</p>



<p>Okay, so some things to point out real fast.</p>



<p>Notice how the tree is lopsided.</p>



<p>to look at various parts of the tree you might be frustrated why didn&#8217;t we put the 98 over there</p>



<p>why didn&#8217;t we put the right just it&#8217;s fine as long as we follow the rules of building a binary search</p>



<p>tree then this is the valid tree that we would have built of course later on you&#8217;ll learn techniques</p>



<p>to make the tree a little bit better looking a little bit faster but right now we&#8217;re just building</p>



<p>a tree with no optimizations no self balancing no anything like that this is our binary search tree</p>



<p>tree if we were to take all of the uh you know all the numbers that we added and sort them</p>



<p>then that should be the numbers we see from left to right this is another good argument for why we</p>



<p>should draw the diagram in this way again like uh same depth nodes let me just draw the the depths</p>



<p>real fast just to kind of illustrate the point a little bit same depth nodes should be on the same</p>



<p>y coordinate or the same uh horizontal plane notice how 73 is the root node and then 12 with 98 have</p>



<p>with 98 have a depth of 1 and then 10 45 and 99 have a depth of 2 and then 11 43 and 67 have a</p>



<p>depth of 3 and then 32 has a depth of 4 so the deepest node we can find has a depth of 4 that&#8217;s</p>



<p>the 32 node which means the height of the tree um height is 4 sorry 5 the height is always the</p>



<p>deepest nodes depth plus 1 or the number of nodes you would have to touch as you found your way</p>



<p>you found your way down to the deepest node for example if we wanted to get to that 32 we would</p>



<p>touch one two three four five nodes so the height of this tree is five</p>



<p>okay um let&#8217;s debug the order of our numbers because this is kind of easy to get wrong</p>



<p>so from left to right we should see a sorted list so let me just uh do little markings here</p>



<p>to indicate that i&#8217;m seeing increasing or at least non-decreasing numbers</p>



<p>If our tree supported duplicates, then it would be non-decreasing.</p>



<p>But since we don&#8217;t allow duplicates, it should be increasing or an ascending list.</p>



<p>So I&#8217;m going to do the 10.</p>



<p>And as we look towards the right, we should see increasing numbers.</p>



<p>So we got the 10 there.</p>



<p>And then we got the 11 there.</p>



<p>And then we got the 12 there.</p>



<p>32, 43, 45, 67.</p>



<p>So far, so good.</p>



<p>It&#8217;s all increasing.</p>



<p>73 increases, 98 increases, and 99 increases.</p>



<p>and 99 increases. So from left to right, it was basically a sorted list, which is what we want.</p>



<p>So we&#8217;ve created a valid ordering for the tree. Now maybe just think about all the rules of a</p>



<p>binary search tree to make sure we did that right too. So is this a graph? Yeah. Is it a connected</p>



<p>graph? Yeah. Is it a tree? You know, no cycles in the graph? Yeah. Is it a rooted tree? Yeah. The 73</p>



<p>root node is the common ancestor of all other nodes. We have one node that&#8217;s common to the</p>



<p>in terms of ancestry um does any node have more than two children no none of the nodes have more</p>



<p>than two children um they&#8217;ve all got zero or one or two children and then the numbers are in order</p>



<p>and therefore this is a valid binary search tree so in other videos i&#8217;m going to talk about the</p>



<p>time complexity and and like you know how fast it is to do certain operations or how imbalanced a</p>



<p>just so you know this is not a perfect binary search tree you can tell because it&#8217;s a little</p>



<p>lopsided um we calculated the height as five and let&#8217;s see where the heck is that calculator i</p>



<p>thought i had a calculator on here oh no oh there it is if we calculated the height as five</p>



<p>you could probably imagine and we&#8217;ll talk about searching in a future video like how do you search</p>



<p>in a way that makes the tree super super fast well we certainly built the tree in a way that</p>



<p>makes it super super fast we just have to get to searching later but if we</p>



<p>search properly through a properly built binary search tree then at most it</p>



<p>should only take us height number of examinations to find our way to any</p>



<p>piece of data or to determine that a piece of data doesn&#8217;t exist for example</p>



<p>I could say that the time complexity is O and we&#8217;ll do this in other videos of</p>



<p>of h no matter what the tree looks like no matter how lopsided it is and what is h here five that</p>



<p>just basically is saying in the worst case scenario i would have to touch five nodes to reach the very</p>



<p>bottom of the tree and determine that a value didn&#8217;t exist or you know find a value at the very</p>



<p>bottom of the tree so the worst case scenario touch five nodes so it&#8217;s o of h if we if we plug</p>



<p>log base 2 so if we did log base 2 of n where n is the number of nodes uh oh how many nodes do we</p>



<p>have shoot one two three four five six seven eight nine ten i think one two three four five six seven</p>



<p>eight nine ten yeah log base two of ten notice how the number here says well it should take like</p>



<p>somewhat close to three uh examinations at most four examinations but we just said it&#8217;s going to</p>



<p>of a divergence between the real speed of the tree.</p>



<p>It might take up to five examinations and log base two,</p>



<p>which would be a perfect binary search tree.</p>



<p>So the more lopsided a tree gets, the slower it actually becomes.</p>



<p>And we&#8217;ll deal with that in future videos.</p>



<p>We&#8217;ll learn how to like detect that and balance that and so forth.</p>



<p>But so we&#8217;ve built a binary search tree.</p>



<p>It&#8217;s definitely valid if not, you know, like super, super fast.</p>



<p>And I think that&#8217;s the end of this video.</p>



<p>Thank you so much for watching.</p>



<p>I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p>In the next video, I think I&#8217;m just going to build another tree for you so we can get</p>



<p>a second practice in.</p>



<p>Okay, future videos also are going to include searching and deleting nodes and modifying</p>



<p>existing nodes and just a whole bunch of other stuff.</p>



<p>Then eventually we&#8217;ll do self-balancing trees.</p>



<p>I&#8217;ll see you later.</p>



<p>Hey everybody.</p>



<p>Hey everybody!</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor, could you please subscribe and follow</p>



<p>this channel or these videos or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p>So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able</p>



<p>I&#8217;ll be able to keep making videos in general.</p>



<p>So please do me a kindness and subscribe.</p>



<p>You know, sometimes I&#8217;m sleeping in the middle of the night</p>



<p>and I just wake up because I know somebody subscribed or followed.</p>



<p>It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me</p>



<p>or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now,</p>



<p>right now you should see a QR code which you can scan in order to go to the website which I think</p>



<p>is also named somewhere at the bottom of this video and it&#8217;ll take you to my main website where</p>



<p>you can just kind of like see all the videos I published and the services and tutorials and</p>



<p>things that I offer and all that good stuff and if you have a suggestion for clarifications or</p>



<p>errata or just future videos that you want to see please leave a comment or if you just want to say</p>



<p>what&#8217;s going on you know just send me a comment whatever i also wake up for those in the middle</p>



<p>of the night i get i wake up in a cold sweat and i&#8217;m like it would really it really mean the world</p>



<p>to me i would really appreciate it so again thank you so much for watching this video and um enjoy</p>



<p>the cool music as as i fade into the darkness which is coming for us all</p>



<p>Thank you.</p>



<p>hey there let&#8217;s talk about uh</p>



<p>hello there hello there let&#8217;s build a binary search tree by just inserting a bunch of numbers</p>



<p>inserting a bunch of numbers and will follow the rules</p>
<p>The post <a href="https://www.NeuralLantern.com/building-a-binary-search-tree-insertion-tutorial/">Building a Binary Search Tree &#8211; Insertion Tutorial</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/building-a-binary-search-tree-insertion-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>BST Terminology: Root, Leaves, Subtrees, Depth, Height, Ancestors &#038; More</title>
		<link>https://www.NeuralLantern.com/bst-terminology-root-leaves-subtrees-depth-height-ancestors-more/</link>
					<comments>https://www.NeuralLantern.com/bst-terminology-root-leaves-subtrees-depth-height-ancestors-more/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 09:25:41 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree basics]]></category>
		<category><![CDATA[binary search tree explained]]></category>
		<category><![CDATA[binary tree terminology]]></category>
		<category><![CDATA[BST ancestors]]></category>
		<category><![CDATA[BST descendants]]></category>
		<category><![CDATA[bst for beginners]]></category>
		<category><![CDATA[BST internal nodes]]></category>
		<category><![CDATA[BST leaf nodes]]></category>
		<category><![CDATA[BST root node]]></category>
		<category><![CDATA[BST subtrees]]></category>
		<category><![CDATA[BST terminology]]></category>
		<category><![CDATA[coding interview prep]]></category>
		<category><![CDATA[computer science trees]]></category>
		<category><![CDATA[data structures tutorial]]></category>
		<category><![CDATA[left subtree]]></category>
		<category><![CDATA[right subtree]]></category>
		<category><![CDATA[tree depth]]></category>
		<category><![CDATA[tree height]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=327</guid>

					<description><![CDATA[<p>This video explains essential binary search tree terminology including root node, internal nodes, external nodes (leaves), left and right subtrees, depth of a node, height of the tree and subtrees, ancestors, descendants, siblings, parent and child relationships using a clear example tree.</p>
<p>The post <a href="https://www.NeuralLantern.com/bst-terminology-root-leaves-subtrees-depth-height-ancestors-more/">BST Terminology: Root, Leaves, Subtrees, Depth, Height, Ancestors &amp; More</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="BST Terminology: Root, Leaves, Subtrees, Depth, Height, Ancestors &amp; More" width="1380" height="776" src="https://www.youtube.com/embed/4iuhXHw26ec?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Quick but thorough run-through of binary search tree terminology: root, leaves, internal nodes, subtrees, depth, height, ancestors, descendants, siblings, left/right child &#8211; everything clearly labeled on a working example.</p>



<p>Great for beginners, interview prep, or reviewing foundational BST concepts before coding insert/search/delete.</p>



<p>00:00 Introduction to BST Terminology<br>00:28 Root Node<br>01:10 Ancestors and Descendants<br>01:58 Children, Grandchildren, and Siblings<br>04:07 Internal Nodes vs External Nodes (Leaves)<br>05:34 Understanding Subtrees<br>06:09 Left Subtree and Right Subtree Examples<br>08:34 Depth of a Node<br>11:02 Height of the Tree<br>12:48 Height of Subtrees<br>17:32 Node Structure and Pointers Overview<br>18:12 Closing Remarks and Call to Action</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there! Let&#8217;s talk about binary search tree terminology. If you saw my</p>



<p>previous video we talked about how to define a binary search tree meaning a</p>



<p>whole bunch of rules so that if the thing you&#8217;re looking at follows all the</p>



<p>rules then you know you&#8217;re actually looking at a binary search tree if not</p>



<p>then not. So see my previous video if you want to know for sure whether you&#8217;re</p>



<p>looking at a binary search tree. For now we&#8217;re just going to talk about some</p>



<p>Okay, so the first thing we should probably obviously talk about is the root node over here.</p>



<p>So I mean, well, in my previous video, we talked about nodes, right?</p>



<p>So this is kind of a graph with a whole bunch of rules on top of it.</p>



<p>That means we have nodes and edges.</p>



<p>So if you look at the very top node here, sometimes also referred to as a vertex,</p>



<p>I think in binary search tree terminology, we usually say nodes.</p>



<p>We usually say nodes. I can&#8217;t actually remember. But so look at the 42 there</p>



<p>That node is the root node of all other nodes. It&#8217;s the highest common ancestor in the entire tree. So this is the root node</p>



<p>First bit of terminology. Also, I tried to sneak past you ancestor</p>



<p>So these trees are supposed to be written in a way that kind of looks like they have a family hierarchy with one parent per</p>



<p>like not two children per parent, but just like one parent and then either zero or one or two</p>



<p>children. So we&#8217;ll say that ancestors are higher on the tree. So that means 42 is actually an</p>



<p>ancestor of 33. And it&#8217;s also an ancestor of 12. It&#8217;s also an ancestor of 19. Just anything that&#8217;s</p>



<p>higher is an ancestor of anything that&#8217;s lower. We could also say that 33 is an ancestor of 39</p>



<p>and 19 and so forth. You can probably also imagine that we have children and grandchildren. Yeah,</p>



<p>we do go that far in binary search trees. So the 42 node, it has two children. It has a left child</p>



<p>and a right child. The 33 is the left child. I&#8217;ll put LC for left child. And the 67 is its right</p>



<p>child. I&#8217;ll put an RC there. The 67 in turn has two children. The 56 has no children of its own.</p>



<p>the 33 has two children the 12 only has one child it was you know playing it safe i guess</p>



<p>you never know if these children are going to come out and just like run amok</p>



<p>and and engage in constant shenanigans so the 12 has a right child but no left child that&#8217;s okay</p>



<p>um in terms of going higher on the tree anything that is higher is an ancestor sorry i should have</p>



<p>said lower anything that&#8217;s higher is an ancestor anything that&#8217;s lower is a descendant so if we&#8217;re</p>



<p>If we&#8217;re looking at the 33 node, the 33 is a descendant of 42 because it&#8217;s the left child of 42.</p>



<p>It&#8217;s also an ancestor of anything that comes below it.</p>



<p>So it&#8217;s an ancestor of 12 and 39 and 19, right?</p>



<p>So if we&#8217;re looking at 33, we&#8217;ve got a left child over here and we&#8217;ve got a right child over here.</p>



<p>And then we have a grandchild, which is the 19 node.</p>



<p>We don&#8217;t really have left and right grandchildren.</p>



<p>You could say a grandchild in the left subtree or the right subtree.</p>



<p>subtree talk about sub trees in a second the 33 has a parent node which is just the 42 node</p>



<p>which is also the root node of course it&#8217;s got a sibling the 67 is the sibling you can tell</p>



<p>something&#8217;s a sibling because it&#8217;s got the same parent as you it&#8217;s the people that you&#8217;re usually</p>



<p>fighting with right anyway so if we&#8217;re looking at any node in particular it might have a whole bunch</p>



<p>of ancestors above the tree it might have a whole bunch of descendants below the tree</p>



<p>It has siblings or it usually has zero or one sibling because in a binary search tree,</p>



<p>we can only have up to two children per node.</p>



<p>It&#8217;s got sometimes, you know, grandparents and great grandparents and children and great</p>



<p>grandchildren.</p>



<p>So just think about the hierarchy like a family tree would have.</p>



<p>Okay, moving on to some more terminology.</p>



<p>Next thing is we have internal nodes and also external nodes.</p>



<p>So what do I mean by internal? Internal means a node has more than zero children. It has one or two children.</p>



<p>So I&#8217;m going to put internal on the 33 because the 33 node has children.</p>



<p>The 12 also has children, so it&#8217;s internal. The 39 does not have children, so it&#8217;s not internal.</p>



<p>67 has children, so it&#8217;s internal. And the root node, 42, also has children, so it&#8217;s considered internal.</p>



<p>That 42 has a lot of different names.</p>



<p>It&#8217;s the root node, it&#8217;s the greatest common ancestor,</p>



<p>it&#8217;s an internal node and so forth.</p>



<p>Notice how the other nodes that I have not highlighted,</p>



<p>they have zero children.</p>



<p>So when a node has zero children,</p>



<p>it&#8217;s known as an external node.</p>



<p>It&#8217;s also known as a leaf</p>



<p>because we&#8217;re talking about trees</p>



<p>and I guess it&#8217;s kind of like a nice synonym.</p>



<p>So the 19, the node with no children of its own is a leaf.</p>



<p>So is the 39.</p>



<p>So is the 56.</p>



<p>So is the 76.</p>



<p>I just want to point out also, if you were with me on my last video,</p>



<p>then the numbers need to be ordered from left to right.</p>



<p>But don&#8217;t worry, we&#8217;re going to do another video where we build a complete tree from scratch.</p>



<p>There&#8217;s some more terminology we should talk about.</p>



<p>So I&#8217;m going to get rid of all these externals and internals real fast.</p>



<p>Or the labels.</p>



<p>We should talk about the left subtree versus the right subtree.</p>



<p>left subtree versus the right subtree i mean what is a subtree anyway the subtree is basically</p>



<p>a subtree is basically just pick any node you want in the entire tree let&#8217;s pick</p>



<p>the 76 and then we&#8217;ll just pretend that it&#8217;s the root node of a separate tree starting with 76 so</p>



<p>if there was anything below it then all those nodes would be included so this 76 right here it</p>



<p>really has nothing underneath it it&#8217;s a leaf which means well it can be the root node of its own</p>



<p>the subtree is just going to be a tree of one node.</p>



<p>So kind of boring, right?</p>



<p>You&#8217;re boring.</p>



<p>If instead we decided to look at the 33,</p>



<p>which is a little bit more interesting,</p>



<p>and we called the 33 the root node of its own subtree,</p>



<p>then really what we&#8217;re saying is all these nodes here</p>



<p>are included in that subtree.</p>



<p>So if I told you, give me the subtree starting with node 33,</p>



<p>then you would say, oh, it&#8217;s 33, 12, 39, 19.</p>



<p>descendants of the subtree root node that we picked out. So subtree just means, you know,</p>



<p>like a little fragment or a portion of the original tree. You could also say that the</p>



<p>entire tree is a subtree of itself. If you chose the subtree root to be the real root node, I mean,</p>



<p>that&#8217;s not super useful, but you can do it. Anyway, so if we decide to say that the 67 is the root of</p>



<p>with 67 and below in terms of descendancy is going to be considered part of the subtree.</p>



<p>I&#8217;ve highlighted the left subtree and the right subtree of the root node because that&#8217;s usually</p>



<p>what we say. We&#8217;ll say this is the left subtree over here and then over here we&#8217;re going to say</p>



<p>this is the right subtree. Meaning if you look at any node at all, if it has a left child,</p>



<p>then that left child is the root node of the left subtree of the node in question. Same thing for</p>



<p>same thing for the right so if I say all right let me duplicate this real fast</p>



<p>let me get rid of actually this real fast too if I say okay give me the left subtree of the 33 node</p>



<p>well then you would know to include the 12 and the 19 because the left subtree of the 30 node</p>



<p>has to the 33 node has to start with the left child of the 33 node which would be the 12 and</p>



<p>And we&#8217;ll just say, okay, the 12 is now the root node of its own subtree.</p>



<p>And then anything that goes below it in descendancy is going to be considered part of that subtree.</p>



<p>So that highlighted subtree is the left subtree of the 33 node.</p>



<p>The 39 is the right subtree of the 33 node.</p>



<p>I think I just did the wrong color.</p>



<p>Let me do that in gray.</p>



<p>Right, so we can do left subtree and right subtree for any node in the entire tree.</p>



<p>if a node has no children, then there are no subtrees, but we can still look and check.</p>



<p>And if there are children, then we&#8217;ve got subtrees or left and right subtrees.</p>



<p>Okay, so now that we&#8217;re done talking about subtrees real fast, let&#8217;s talk about the depth of a node.</p>



<p>So for me, I like to say that the depth of the root node is zero.</p>



<p>And so I&#8217;ll just, I guess we could start off by putting a zero on the 42 indicating it has zero depth.</p>



<p>It has zero depth.</p>



<p>Imagine maybe it&#8217;s a buoy in the water and it&#8217;s just like sitting, floating like directly</p>



<p>on the water.</p>



<p>So it has no depth.</p>



<p>It&#8217;s just like kind of on the surface.</p>



<p>But if you draw your binary search trees in this nice pretty way where every single time</p>



<p>you go down a generation from parent to child, from parent to child, you maintain, I guess,</p>



<p>like the same Y coordinate for same leveled nodes, then it&#8217;s really easy to calculate</p>



<p>the depth of every single node.</p>



<p>of every single note let me show you what show you what i mean real fast you saw my video uh</p>



<p>previously then you already know this but the 42 it&#8217;s got two children so if i go down to get one</p>



<p>of its children i&#8217;m going down to the 33 and then i&#8217;m going down to the 67 right since those two</p>



<p>children are on the same i guess level as if we were looking at a family tree they should be</p>



<p>physically on the same level they should be on the same y coordinate or the same horizontal plane</p>



<p>plane if we go down one more level which means any child of 33 or any child of 67 then those all</p>



<p>should be lined up also so notice how these are all lined up on the same y coordinate then if we</p>



<p>go down another level then this 19 here is just kind of by itself because the tree is not very big</p>



<p>so if we draw the tree like this which is a really smart way because uh it&#8217;s easier to debug</p>



<p>whether it&#8217;s a valid binary search tree and all sorts of other things,</p>



<p>then we can easily write down the depth kind of on the side of the graph.</p>



<p>We can say, all right, here&#8217;s depth zero, and here&#8217;s depth one,</p>



<p>and here&#8217;s depth two, and here&#8217;s depth three.</p>



<p>Just every time you go down one level, you just increase the depth.</p>



<p>And now you know the depths of all the nodes in the entire tree pretty quickly.</p>



<p>The 19, I&#8217;m just going to maybe do this in red.</p>



<p>the 56 and the 76 have a depth of 2, the 33 has a depth of 1, and the 42 has a depth of 0.</p>



<p>So all these trees, sorry, all these nodes in the tree have their own depth,</p>



<p>which are very easy to calculate if you draw the tree well. The next thing after depth is the height</p>



<p>of the tree. So what is the height of the tree? Well, that&#8217;s basically the depth of the deepest</p>



<p>to the very deepest node what is the minimum number of nodes that you must touch when you</p>



<p>start at the root node and then find your way to the deepest possible node in the entire tree so</p>



<p>um if you if you notice the 19 node is definitely the deepest node in the entire tree</p>



<p>it&#8217;s got a depth of three which means the height of the entire tree is four heights</p>



<p>equals four and maybe i&#8217;ll change that to like just black or something okay</p>



<p>So, let&#8217;s do it the other way real fast.</p>



<p>If we&#8217;re kind of just walking down the tree, let&#8217;s start at the 42 and then we go down</p>



<p>to the 33, we&#8217;ve touched two nodes so far.</p>



<p>We go down to the 12, we&#8217;ve touched three nodes.</p>



<p>We go down to the 19, we&#8217;ve touched four nodes.</p>



<p>So the height of the tree is four or the number of nodes that you need to touch as you make</p>



<p>your way down towards the deepest node or just a shortcut is the deepest nodes depth</p>



<p>plus one.</p>



<p>And that&#8217;s the height of the tree.</p>



<p>you can also have a height of a left subtree and a height of a right subtree so let me just</p>



<p>what&#8217;s going on here i think my thing is crashing hello oh i was definitely crashing i think my cpu</p>



<p>is burning right now all right i&#8217;m going to be complaining about my new cpu for a long time</p>



<p>i sprung only a few bucks for the best cpu that this motherboard could hold but it&#8217;s an old</p>



<p>something percent um i&#8217;m eventually going to have to like build a brand new computer</p>



<p>anyway so uh suppose we&#8217;re looking at the 67 node and the question is you know what is the height</p>



<p>of the left subtree of the 67 node versus the right subtree of the 67 node well if you recall</p>



<p>the left subtree is just all the nodes that are included uh beginning with the root node of the</p>



<p>subtree of the 67 node well that&#8217;s just the 56 node totally by itself what&#8217;s the right subtree</p>



<p>of the 67 it&#8217;s just that 76 node all by itself what&#8217;s the depth of 56 and 76 they&#8217;re both depth</p>



<p>zero if we&#8217;re talking about relative depths per their subtrees that means what is the height of</p>



<p>the left subtree and the right subtree they&#8217;re just one because the depth is zero the maximum</p>



<p>depth is zero and if we want to get to the deepest node in one of those subtrees we&#8217;re just</p>



<p>end up touching the one node that&#8217;s in the in the subtree at all so that means uh</p>



<p>uh i don&#8217;t want to write down uh left subtree height right now so left subtree height of 67</p>



<p>is one right subtree height of 67 is also one so we can do this with any node we want you know what</p>



<p>is the uh what is the situation with the 33 node let&#8217;s do uh the 33 node yeah uh it has a left</p>



<p>It has a left subtree height of 2 and you can tell because, well, the left subtree starts with the left child and the left child is going to be the root node of its own subtree.</p>



<p>Notice how the maximum depth we can find here is 1, right?</p>



<p>Like if we start at depth 0 for the 12, considering like it&#8217;s a relative depth, that means we take the deepest node, which is the 19 node, which has a depth of 1.</p>



<p>We add 1 to that.</p>



<p>So that means the height of that subtree is 2.</p>



<p>if you wanted to find the deepest node in that whole subtree, how many nodes would you have to</p>



<p>touch to get there? We&#8217;d have to touch the 12 and then touch the 19. We touch two nodes, so the height</p>



<p>of that subtree is two. Maybe I&#8217;ll just put H equals two here. So now for the right subtree of</p>



<p>the 33 node, it&#8217;s kind of easier. We just basically only have one node to really look at.</p>



<p>that means that 39 has a depth of 0 and the right subtree has a height of 1.</p>



<p>Whoops, 8 equals 1.</p>



<p>I didn&#8217;t put two equal signs. I like to do two.</p>



<p>I like to do the comparison operator.</p>



<p>We could also do the same thing with the 42 node, right?</p>



<p>We can say, let&#8217;s get rid of all this stuff real fast.</p>



<p>We can do the 42.</p>



<p>Its left subtree starts with that 33 node.</p>



<p>33 node so I&#8217;m just going to highlight that real fast the 42 nodes left subtree has a height of</p>



<p>one two three and you can tell because the 33 has a depth of zero a relative depth of zero and</p>



<p>the 12 and the 39 have one and the 19 has two so the deepest node has a depth of two</p>



<p>so that means the height of that subtree is is three so I&#8217;m just going to like do this real fast</p>



<p>and then the right subtree of the 42 node, the root node of the entire tree, is going to be this.</p>



<p>So the root node has a depth of zero, depth of zero, and then these other leaves over here have</p>



<p>depth of ones, which means the height of this subtree is going to be two, or the deepest node</p>



<p>plus one, or the number of nodes you need to touch to find the deepest node. And 56 and 76,</p>



<p>those are both equally the deepest node in those trees okay so we talked about a bunch of</p>



<p>terminology here let me just double check my notes in case I forgot to to tell you anything</p>



<p>I think I&#8217;m all right well maybe okay maybe I should real fast just briefly mention that these</p>



<p>nodes I mean this is not really part of the video exactly but let&#8217;s let me just mention that these</p>



<p>whoops that&#8217;s dumb let me do a blue circle they would have you know there&#8217;s</p>



<p>like some sort of an object you would call it a node and then they would have</p>



<p>pointers they would have each of these nodes would have a pointer to its</p>



<p>parents and it would have a left child pointer that goes down into the left and</p>



<p>a right child pointer that goes down to the right and also a little slot in that</p>



<p>object for the data so I&#8217;m just going to put t type data and C++ I usually say</p>



<p>I usually say that the templated data type for a node or data structure is just the T type.</p>



<p>That just means you could put anything you want.</p>



<p>You could have your nodes hold integers, letters, strings, custom objects, whatever you want to do.</p>



<p>And we&#8217;ll talk about this more in future videos.</p>



<p>But long story short, I want you to just imagine that every node actually has three pointers inside of it pointing to something else, to other nodes,</p>



<p>graph because in a graph you could have like a whole bunch of different connections and that&#8217;s</p>



<p>usually managed by the actual graph object itself so anyway we&#8217;re done with terminology i hope you</p>



<p>learned a little bit of stuff and had a little bit of fun thanks for watching this video</p>



<p>tell your friends eat a donut and a chocolate and then be really happy and stuff okay i gotta go</p>



<p>Hey everybody!</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor,</p>



<p>could you please subscribe and follow this channel or these videos</p>



<p>or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos</p>



<p>and grow this community.</p>



<p>So we&#8217;ll be able to do more videos, longer videos, better videos,</p>



<p>or just I&#8217;ll be able to keep making videos in general so please do do me a</p>



<p>kindness and and subscribe you know sometimes I&#8217;m sleeping in the middle of</p>



<p>the night and I just wake up because I know somebody subscribed or followed it</p>



<p>just wakes me up and I get filled with joy that&#8217;s exactly what happens every</p>



<p>single time so you could do it as a nice favor to me or you could you control me</p>



<p>if you want to just wake me up in the middle of the night just subscribe and</p>



<p>then I&#8217;ll just wake up I promise that&#8217;s what will happen also if you look at the</p>



<p>at the middle of the screen right now you should see a qr code which you can scan in order to go</p>



<p>to the website which i think is also named somewhere at the bottom of this video and it&#8217;ll</p>



<p>take you to my main website where you can just kind of like see all the videos i published and</p>



<p>the services and tutorials and things that i offer and all that good stuff and uh</p>



<p>if you have a suggestion for uh clarifications or errata or just future videos that you want to see</p>



<p>say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also wake up for</p>



<p>those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like it would really it</p>



<p>really mean the world to me i would really appreciate it so again thank you so much for</p>



<p>watching this video and um enjoy the cool music as as i fade into the darkness which is coming for us</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/bst-terminology-root-leaves-subtrees-depth-height-ancestors-more/">BST Terminology: Root, Leaves, Subtrees, Depth, Height, Ancestors &amp; More</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/bst-terminology-root-leaves-subtrees-depth-height-ancestors-more/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Binary Search Tree Definition Explained Step by Step</title>
		<link>https://www.NeuralLantern.com/binary-search-tree-definition-explained-step-by-step/</link>
					<comments>https://www.NeuralLantern.com/binary-search-tree-definition-explained-step-by-step/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Tue, 31 Mar 2026 03:10:16 +0000</pubDate>
				<category><![CDATA[Binary Search Trees]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[acyclic graph]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[binary search tree definition]]></category>
		<category><![CDATA[binary search tree explained]]></category>
		<category><![CDATA[binary tree vs binary search tree]]></category>
		<category><![CDATA[bst]]></category>
		<category><![CDATA[bst for beginners]]></category>
		<category><![CDATA[bst ordering property]]></category>
		<category><![CDATA[bst rules]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[connected graph]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[left subtree right subtree]]></category>
		<category><![CDATA[rooted binary tree]]></category>
		<category><![CDATA[tree data structure]]></category>
		<category><![CDATA[what is a binary search tree]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=324</guid>

					<description><![CDATA[<p>A Binary Search Tree (BST) is a rooted binary tree where for every node, all values in its left subtree are less than the node's value, and all values in its right subtree are greater than the node's value. No duplicates in this simple version.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-definition-explained-step-by-step/">Binary Search Tree Definition Explained Step by Step</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Binary Search Tree Definition Explained Step by Step" width="1380" height="776" src="https://www.youtube.com/embed/H1BU1UkFiDo?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Clear step-by-step explanation of what defines a Binary Search Tree (BST). We build the definition rule-by-rule starting from graphs all the way to the BST ordering property (all left descendants, node, all right descendants). Great first video before learning insert, delete, search, and Big-O.</p>



<p>What is a Binary Search Tree? 00:00<br>Intro to Graphs and Nodes 00:42<br>Connected Graph Requirement 03:16<br>Acyclic Graph &#8211; Removing Cycles 04:54<br>Turning Graph into Tree 07:05<br>Establishing a Root 07:09<br>Adding Hierarchy and Levels 09:05<br>Single Common Ancestor 11:18<br>Binary Tree Definition 17:30<br>BST Ordering Property 17:39<br>Left Subtree Less Than Node 18:29<br>Fixing Invalid BST Example 20:26<br>Valid BST Final Check 21:24<br>In-Order Ascending Order 24:11<br>Video Summary and Next Steps 25:02<br>Thanks and Call to Action 25:30</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>hey there let&#8217;s talk about binary search trees specifically in this video I want to help you</p>



<p>define and identify what is a binary search tree all the rules that go into determining whether</p>



<p>or not something is a binary search tree so you can you can tell that you&#8217;re looking at one or</p>



<p>whether you&#8217;re not looking at one we&#8217;ll talk about some terminology but keep in mind I&#8217;m</p>



<p>going to save searching and sorting and like you know deleting and adding items and a whole bunch</p>



<p>extra stuff, especially the hard stuff for videos that&#8217;ll come right after this one.</p>



<p>For now, we&#8217;re just going to talk about what is a binary search tree.</p>



<p>So you can see on the screen right here, I hope that we have a binary search tree.</p>



<p>Let&#8217;s see.</p>



<p>Can you see that?</p>



<p>Yeah, I think you probably can.</p>



<p>Yeah, I think you can.</p>



<p>This is not drawn quite as well as I would like to draw ours.</p>



<p>I&#8217;ll tell you how to do that in a little while.</p>



<p>to do that in a little while but when you draw a tree in a really really nice pretty aligned way</p>



<p>it&#8217;s way easier to debug it&#8217;s way easier to tell that you&#8217;re looking at something that is sorted</p>



<p>and so forth anyway okay so first let&#8217;s start off with a graph so this is not a video about graphs</p>



<p>uh i guess i can probably expect that you already kind of know what a graph is at this point in time</p>



<p>and edges. So what do I mean by nodes? Well just imagine there&#8217;s like a little circle here</p>



<p>that contains some sort of data. If you know data structures already then</p>



<p>there would be a t-type sitting inside the node. We&#8217;ll just call the t-type an integer</p>



<p>and so for our nodes, for our trees, we&#8217;re just going to say that they hold integers even though</p>



<p>you know technically speaking in a binary search tree or a graph you could have all sorts of</p>



<p>Okay. So I&#8217;m just going to, you know, grab this and sort of like duplicate it and just duplicate it again.</p>



<p>I&#8217;m just going to make a bunch of duplicates. Something is definitely wonky about my setup right now.</p>



<p>I think I just upgraded the camera and the CPU is maxed out. I just upgraded the CPU on this computer too.</p>



<p>Oh well. Okay. So we aren&#8217;t going to support duplicate values in our binary search tree,</p>



<p>I&#8217;m going to say it doesn&#8217;t really matter for the graph. Later on, we&#8217;ll start making sure there&#8217;s</p>



<p>no duplicate data. For now, I think I can probably do that somewhat quickly. Let&#8217;s see. So a graph,</p>



<p>you know, for the for our purposes right now, a graph is just basically a collection of nodes and</p>



<p>edges. It could be empty. It could be just nodes. It couldn&#8217;t just be edges, it would have an edge</p>



<p>always has to have a node or two connected to it. So we just have like a bunch of nodes inside of</p>



<p>data values this is a valid graph but I&#8217;m going to draw some edges randomly here so we&#8217;re going</p>



<p>to do this it doesn&#8217;t really matter I&#8217;m just randomly drawing edges okay actually I should</p>



<p>probably do maybe like one that&#8217;s kind of separated okay so this is a graph this is not a binary search</p>



<p>tree so let&#8217;s add a bunch of rules let me just pull up my rules real fast here okay so what is</p>



<p>First we&#8217;ll start off with the graph like we have here and then we&#8217;ll say that the graph must be connected.</p>



<p>What is a connected graph? A connected graph is basically a graph where every single node can find every single other node</p>



<p>or find a path to every single other node only following along edges and only by respecting the direction of edges.</p>



<p>You can see this particular graph is undirected meaning the edges don&#8217;t really have a direction to them.</p>



<p>So that means we could travel along in any direction from node to node.</p>



<p>So just as a real quick, you know, I guess like tutorial, I&#8217;m going to say is 8 connected to every single other node?</p>



<p>Well, it can find a path to 12 and it can find a path to 33 and it can find a path to 76 and 45.</p>



<p>But it cannot find a path to 99, which means this is not a connected graph.</p>



<p>So that&#8217;s the first rule that we have to implement here.</p>



<p>We&#8217;re going to say this graph needs to be upgraded or modified so that it will be a connected graph.</p>



<p>start randomly adding edges until this is a connected graph I&#8217;m gonna do maybe</p>



<p>like an edge from 99 to 12 there and then now I think this is a connected</p>



<p>graph but let&#8217;s double check real fast so connected graph you know what I&#8217;m</p>



<p>gonna put graph connectedness in another video to keep this one short for now</p>



<p>check out my other videos if you would like to see whether or not a graph is</p>



<p>but long story short as I just said if every single node can find a path to</p>



<p>every single other node without you know skipping where there is no edge then</p>



<p>it&#8217;s connected okay so that&#8217;s the first thing the next thing that we need let me</p>



<p>just put the words connected up here we need a connected graph the next thing</p>



<p>that we need is we need an acyclic graph which basically means a graph with no</p>



<p>A cycle is, can you find a path in this graph that starts at one node and ends at the same node without repeating any edges?</p>



<p>So for example, if I was asking, you know, is 76 involved in any cycles?</p>



<p>Well, we could go from 76 to 33 and then 12.</p>



<p>And, you know, we could kind of take 8, 45, 12 again.</p>



<p>But by the time we turn around and try to get back to the 33, we&#8217;ve already crossed this edge twice.</p>



<p>so that means the 76 is not involved in any cycles because we cannot find our way back to 76</p>



<p>without repeating an edge so 76 is okay i&#8217;m just going to maybe put like a little check box here</p>



<p>and uh you can also tell that the 33 is not involved in any cycles because we go down to</p>



<p>the 76 and then come back up to 33 we already repeated an edge so that&#8217;s not valid same thing</p>



<p>again. Same thing for the 34, same thing for the 99. But if you look at the 12 here, we could</p>



<p>actually find a cycle. We could go from the 12 to the 8, and then from the 8 to the 45, and from the</p>



<p>45 to the 12. Now we&#8217;re back where we started. We&#8217;re at the 12 node again, and we did not repeat</p>



<p>any edges. So this is not a cyclic. This is a cyclic graph. It&#8217;s got a cycle. So that&#8217;s the</p>



<p>we want to make sure that our graph has no cycles. So, uh, the next rule I&#8217;m just going to say is,</p>



<p>is going to be satisfied by me removing some edges at random. So I don&#8217;t know, let&#8217;s get rid of, uh,</p>



<p>the eight to the 45 connection. See if that works. Um, let&#8217;s see. Well, wait a minute. What did I</p>



<p>just do? Something happened here. I just accidentally, oh, I erased too many edges</p>



<p>from the last slide. Okay. Let me add that one back in 33 to 76. That was supposed to be there.</p>



<p>33 to 76 that was supposed to be there.</p>



<p>So now we have an acyclic graph</p>



<p>and we can consider this graph a tree.</p>



<p>The next thing we need to do is add a hierarchy to this tree.</p>



<p>So this is gonna make more sense in a little bit</p>



<p>but for now I&#8217;m gonna say,</p>



<p>we&#8217;ll imagine a family tree kind of,</p>



<p>it&#8217;s not really exactly a family tree</p>



<p>but you know imagine there are parents</p>



<p>and children and grandchildren</p>



<p>and we&#8217;ll just try to like,</p>



<p>we&#8217;ll try to rank children according to</p>



<p>according to you know when they were born or or how many parents or children</p>



<p>they have you know their descendancy their lineage whatever you want to call</p>



<p>it so I think I&#8217;m just gonna maybe move the eight up a little bit so that it&#8217;s</p>



<p>on the same rank with the 12 and the 33 so I&#8217;m just gonna move these up a little</p>



<p>bit and then redo their connecting lines so I&#8217;m gonna do this and that and then</p>



<p>and then we&#8217;ll say that the 76 is still a child of the 33.</p>



<p>So I&#8217;ll just kind of move it over here.</p>



<p>Or sorry, we never said it was a child.</p>



<p>Now we&#8217;re saying it&#8217;s a child</p>



<p>because when you go from top to bottom,</p>



<p>imagine like a family tree,</p>



<p>we&#8217;ll say we have parents and children.</p>



<p>The children or the descendants are lower.</p>



<p>The ancestors or the parents or the grandparents are higher.</p>



<p>Maybe I want to put this 45 over on the left</p>



<p>so that it&#8217;s a child of the 8 node.</p>



<p>And maybe I&#8217;ll say that the 99 node</p>



<p>the 99 node is a child of the 12 node. Okay, so eventually this is going to look not exactly like</p>



<p>a family tree because usually in the family tree we have two parents that go to one or more children.</p>



<p>In this type of tree, in eventually our binary tree, we&#8217;re going to have one parent that has,</p>



<p>you know, children just by itself, like asexual reproduction. We&#8217;re pretending to be bacteria</p>



<p>What was that comedy skit a long time ago, Tiny Elvis?</p>



<p>And he was like, hey, see that protozoa over there?</p>



<p>The thing is huge.</p>



<p>Anyone?</p>



<p>No?</p>



<p>Okay.</p>



<p>So the next rule we need is we must have a rooted tree.</p>



<p>What is a rooted tree?</p>



<p>Actually, let me clean up the lineage real fast, the heritage.</p>



<p>I want to make nodes that have the same level with respect to their ancestors</p>



<p>respect to their ancestors to have the same physical y coordinate the same</p>



<p>physical level so notice how the 99 I just moved it down a little bit because</p>



<p>I wanted it to look like it&#8217;s the same you know number of generations lower</p>



<p>than the top row so like with aid it had a child 45 so that&#8217;s one level down 33</p>



<p>had a child that&#8217;s one level down that&#8217;s a 76 and the 12 also one level down</p>



<p>would have been 99 but the 99 was kind of too physically high this will help</p>



<p>will help you debug your binary trees in the future anyway so i&#8217;m just going to clean this up right now</p>



<p>and uh now that we have you know parent child relationships we need to look at the most common</p>



<p>ancestor in the whole entire tree or if there is one so notice how uh i guess i&#8217;m just kind of using</p>



<p>the word ancestor without explaining it so your ancestors are the people that you&#8217;re disappointing</p>



<p>or whatever it is, ancestors came before us, right?</p>



<p>Like my parents are my ancestors.</p>



<p>My grandparents are also my ancestors.</p>



<p>My great-grandparents are also my ancestors.</p>



<p>Going down in the family tree are your descendants.</p>



<p>You know, my children are my descendants.</p>



<p>My grandchildren are my descendants.</p>



<p>My great-grandchildren are my descendants and so forth.</p>



<p>So if you look at the number 34 here,</p>



<p>what is the greatest ancestor that it has?</p>



<p>Well, if you just go up and up and up</p>



<p>until you can&#8217;t go up anymore,</p>



<p>up until you can&#8217;t go up anymore it&#8217;s the 12th so that means the greatest ancestor of at least in</p>



<p>this tree of the 34 is the 12th the 45 the highest you can go is the 8 notice how 8 and 12 and 33 are</p>



<p>siblings there&#8217;s not really like a parent-child relationship they&#8217;re connected sideways we&#8217;ll</p>



<p>eventually get rid of the sideways connections for our binary search trees but for now we have</p>



<p>some siblings and so we actually have three different greatest ancestors in this tree we&#8217;ve</p>



<p>tree we&#8217;ve got 8 and 12 and 33 and that&#8217;s no good so the next rule that we need is we need</p>



<p>one common ancestor for every single other node in the entire tree so I&#8217;m going to duplicate this</p>



<p>slide right here and I&#8217;m going to say we need to clean this up so we got to choose 8 or 12 or 33</p>



<p>I don&#8217;t know I&#8217;m just going to maybe say that 8 and it&#8217;s 45 are children of the 12 so I&#8217;m just</p>



<p>line here arbitrarily so i&#8217;m gonna go like that notice how i&#8217;m trying to keep the 8 the 99 and</p>



<p>the 76 on the same y coordinate the same level now we have two uh you know greatest ancestors</p>



<p>we need to have only one so i think i&#8217;m probably going to say that the 33 and the 76 are going to</p>



<p>become children of the 12 node just for simplicity so i&#8217;m going to put this over here i&#8217;m going to</p>



<p>i&#8217;m gonna like move this over here this is a gross tree but we&#8217;ll fix it soon we&#8217;ll do that all right</p>



<p>okay okay</p>



<p>okay and then i have to get rid of that little sibling line and then i have to add another line</p>



<p>to say that 33 is a child of 12. okay so now we have a rooted tree what we had before was an</p>



<p>unrooted tree or just like not a rooted tree because there was no root there was no greatest</p>



<p>greatest common ancestor to the entire rest of the tree. But now we can say that 12 is the root</p>



<p>of the tree because it&#8217;s the ancestor for all other nodes. I guess even if 12 was by itself,</p>



<p>we could call it a root of tree. It just wouldn&#8217;t be a very good example. So I&#8217;m going to actually</p>



<p>get rid of the word acyclic here since we already handled that. And I&#8217;m going to do,</p>



<p>I&#8217;m going to say that 34&#8217;s greatest ancestor is 12, 99&#8217;s greatest ancestor is 12, 33&#8217;s greatest</p>



<p>all the nodes in the tree their greatest ancestor is 12 and it&#8217;s common to all of them so now we</p>



<p>have a rooted tree maybe I should type in my doomed I really hope the screen I really hope</p>



<p>the screen cast doesn&#8217;t freeze it probably will upgraded the CPU it&#8217;s 33 faster than it was before</p>



<p>board so i am still using an old cpu even though it&#8217;s new to me dang it i&#8217;m gonna have to spend</p>



<p>like 500 okay uh so the next rule is so we have a rooted tree and now let&#8217;s rearrange everything</p>



<p>hierarchically which we already kind of did so uh there&#8217;s not really much to do here except</p>



<p>we did hierarchical organization</p>



<p>we probably just need to move on to our next rule which is to say that</p>



<p>if our rooted tree is to become a binary tree</p>



<p>then each node in the entire tree</p>



<p>cannot have more than two children</p>



<p>every single node in the entire tree</p>



<p>can have zero or one or two children</p>



<p>if there are three or more anywhere in the entire tree</p>



<p>then it&#8217;s not a binary tree</p>



<p>so okay that means you know the 45 is okay</p>



<p>because it has no children</p>



<p>because it has no children. All the rows, all the leaves at the bottom are okay. All these nodes</p>



<p>over here are okay because they just have one child. But the 12 node, the root of the tree,</p>



<p>it&#8217;s got three children and that violates the rule. So now we need to rearrange this.</p>



<p>So I think I&#8217;m going to just move these numbers down here maybe. Whoops. Maybe move these nodes</p>



<p>descendants of the 33 node. So I&#8217;m going to do this.</p>



<p>Okay. So cool. Now we have a binary tree and now we need to rearrange the drawing a little bit.</p>



<p>This is not part of the definition, but this will make it easier to debug your trees. So what I want</p>



<p>to do is make it so that every left descendant of a node appears physically on that node&#8217;s left</p>



<p>every right descendant of a node should appear on its right side</p>



<p>or like further to the right on the x-coordinate</p>



<p>so sort of similar to you know like the y-coordinate ranking</p>



<p>but notice how the 12 its left child is 8 and its right child is 33</p>



<p>so that means all the nodes here on the left side you know that come underneath the 8</p>



<p>are left descendants or you could say that they are in the left subtree of the 12.</p>



<p>So, they&#8217;re okay because 8 is to the left of 12 and 45 is to the left of 12.</p>



<p>But notice how 33 is a right child of 12 and it&#8217;s part of the right subtree.</p>



<p>It&#8217;s part of the right descendancy, but it&#8217;s physically on the left of 12.</p>



<p>That&#8217;s going to be really bad because it&#8217;ll be harder to debug our trees later.</p>



<p>So, I&#8217;m just going to slide it over without rearranging the tree.</p>



<p>And I usually try to split the difference here.</p>



<p>and then their parent is kind of like physically in the middle that will also help you debug in</p>



<p>the future so i&#8217;m going to do this wrong let me get the blue i&#8217;m going to do this make sure that</p>



<p>my ranking is still okay not the best most neatest tree and so now i&#8217;m going to look at the eight</p>



<p>it&#8217;s left subtree or it&#8217;s left uh descendancy uh all of those nodes which is just the 45 are</p>



<p>it&#8217;s left child 76 is the only thing that&#8217;s on the left side in the left subtree so that&#8217;s all</p>



<p>right probably the 33 I think it&#8217;s still a little lopsided I probably could have you know dragged</p>



<p>it a little bit more to the right but I&#8217;m going to leave it so the 33 and the 76 are okay and then</p>



<p>the 99 is a right descendant or it&#8217;s part of the right subtree of the 33 so it should be on the</p>



<p>right side it is that&#8217;s good the 34 should be on the right side of the 33 because it&#8217;s it&#8217;s a it&#8217;s</p>



<p>It&#8217;s part of the right subtree of 33.</p>



<p>It&#8217;s part of the right descendancy.</p>



<p>And it should also be on the left side of the 99</p>



<p>because it&#8217;s part of the left subtree of the 99.</p>



<p>So, so far, this is okay.</p>



<p>This is not the best drawing.</p>



<p>So now we have a binary tree</p>



<p>and we have kind of drawn it in a slightly good way.</p>



<p>Not super great.</p>



<p>The last rule that we&#8217;re going to add here is,</p>



<p>whoops, what happened there?</p>



<p>I&#8217;m supposed to do that, yeah.</p>



<p>The last rule we&#8217;re going to add is</p>



<p>we must have ordering to our nodes, to the numbers in our nodes. So what do I mean by ordering? Well,</p>



<p>the whole reason that we want a binary search tree, at least usually, is because it&#8217;s really,</p>



<p>really fast to search through. This is going to be a tree that we can search through in log time,</p>



<p>which we&#8217;ll talk more about in another video. We&#8217;ll do time complexities and searching and stuff. But</p>



<p>in order for this to be a super fast tree to search through, we need to be able to</p>



<p>very quickly make a decision. Do we go down and to the left? Do we go down and to the right?</p>



<p>left do we go down into the right and every decision we make should help us eliminate half</p>



<p>of the remaining data set half of the tree at a time every time we go down a level and that&#8217;s only</p>



<p>possible if the nodes themselves are ordered so what i&#8217;m going to do is say every node that&#8217;s on</p>



<p>the left side or let&#8217;s say every descendant that&#8217;s on the left side of a node should be of a lesser</p>



<p>value than that particular node every node that is on the right side of a node meaning it&#8217;s a right</p>



<p>descendant of that node or part of the right subtree of the node should be greater than that</p>



<p>node. Please note that this would not allow us to support duplicate values in our tree.</p>



<p>You could use something like less than or equal to versus greater than if you wanted to support</p>



<p>duplicate values in your tree. You could also change the T type, you know, the template type</p>



<p>to a node from the data you want it to store to a list. So every single node has a list inside of it</p>



<p>and the items in the list are just, you know, the regular values that you wanted. There&#8217;s a whole</p>



<p>values that you wanted there&#8217;s a whole bunch of different ways you could actually do that</p>



<p>but for now we&#8217;re going to see our trees don&#8217;t support duplicate values</p>



<p>so okay we don&#8217;t support duplicate values but we need you know from left to right</p>



<p>the order needs to look sane and this is kind of why we&#8217;re drawing the tree in this special way</p>



<p>we&#8217;re trying to make our tree really easy to debug visually so check this out the way we&#8217;ve</p>



<p>drawn this every single node has its own x coordinate basically notice how the 12 there&#8217;s</p>



<p>nothing underneath it at least not directly underneath it the 33 the 34 all the nodes you</p>



<p>know you can draw a straight line down from the node and it shouldn&#8217;t cross over with any other</p>



<p>nodes or edges so that means now that we&#8217;ve drawn it this way and we&#8217;ve made sure that all the left</p>



<p>descendants are on the left and all the right descendants are on the right we could actually</p>



<p>just scan our eyes from left to right and be sure that we are seeing an increasing order or</p>



<p>Since duplicates aren&#8217;t allowed in this tree, we&#8217;ll say an increasing order or an ascending order.</p>



<p>So if we start at 45 and then we go to the right, we should see a higher number.</p>



<p>So if we look at 8, 8 is a lower number.</p>



<p>So this violates the ordering rule.</p>



<p>This is not a valid binary search tree.</p>



<p>It&#8217;s only a valid binary tree.</p>



<p>So sad.</p>



<p>Okay, so I could, you know, swap the 45 and the 8 or I could just increase the value of the 8 itself.</p>



<p>of the 8 itself, I think it&#8217;ll be faster for me to just increase the 8 value. So I&#8217;m going to make</p>



<p>it 52 now. So we&#8217;ve got 45, 52. Then we go to the right a little bit more. It should also increase.</p>



<p>So 52 should increase. I&#8217;m just going to randomly increase it to, you know, 59, let&#8217;s say. Then as</p>



<p>we go to the right, we see another number here. It is 76. That already is increased from 59.</p>



<p>So we don&#8217;t need, we don&#8217;t need to alter that number. Then we go to the right one more time</p>



<p>that because it&#8217;s lower than 76 so I&#8217;m going to put 87 then when we go to the right one more time</p>



<p>that&#8217;s the 34 down here that&#8217;s definitely a decrease so we have to increase it now so I&#8217;m</p>



<p>going to say 99 how about if I just do 92 yeah so now we have a 92 down here and then if we go</p>



<p>to the right a little bit more there&#8217;s the 99 and now we actually have a binary search tree let&#8217;s</p>



<p>just double check all the rules first off is this a graph yeah there&#8217;s nodes and edges there&#8217;s nothing</p>



<p>There&#8217;s nodes and edges.</p>



<p>There&#8217;s nothing weird happening.</p>



<p>There&#8217;s not like a edge floating in the middle of nowhere.</p>



<p>Is this a connected graph?</p>



<p>Yeah, it is.</p>



<p>Because every single node, if you followed, you know, the edges, you know, could find</p>



<p>every single other node.</p>



<p>Like the 45, it could find, you know, the 92 node if it just followed all these edges.</p>



<p>Notice again that these edges have no direction.</p>



<p>There&#8217;s no arrows on them.</p>



<p>So we could go up or down in any direction we want.</p>



<p>So that means the 76 can find everything else.</p>



<p>else and so this is a connected graph for sure okay now that we have a</p>



<p>connected graph is this an acyclic graph I don&#8217;t know about you but I can&#8217;t find</p>



<p>any cycles in the graph right like the 92 it goes out but it doesn&#8217;t come back in</p>



<p>same thing for the 76 if we went from the 76 up to the 87 and then took a</p>



<p>right turn we wouldn&#8217;t be able to come back towards it without repeating that</p>



<p>same edge so this is definitely an acyclic graph all of the nodes follow</p>



<p>they&#8217;re not involved in cycles is this a rooted tree yeah there&#8217;s only one common ancestor to the</p>



<p>entire tree it&#8217;s the 59 it&#8217;s the highest node in the entire tree and it&#8217;s common to all other of</p>



<p>all of its descendants um so let&#8217;s see i&#8217;m going to duplicate this real fast the next thing is</p>



<p>we arranged it hierarchically and we added the terminology of like i think i kind of just like</p>



<p>tried to sneak this one past you but we added the terminology of a left child and a right child</p>



<p>and a right child.</p>



<p>Right? We also added the terminology of a right subtree and a left subtree.</p>



<p>Just to clarify what I mean, what do I mean by a right subtree and a left subtree.</p>



<p>So imagine we&#8217;re considering the 59.</p>



<p>If we consider the 59, then the 52 is the root node of the left subtree of the 59 node.</p>



<p>If we consider the 59, then the 87 is the root node of the right subtree of the 59 node.</p>



<p>so the right child is basically the root of the subtree uh in in you know the right child is the</p>



<p>root of a subtree of the right subtree uh i think i&#8217;m getting muddled my words here okay</p>



<p>anyway so we have a little bit of terminology uh the 59 is the root node that&#8217;s like the</p>



<p>the only node in the entire tree without uh an ancestor or a parent so okay uh then we have a</p>



<p>Note, and the entire tree doesn&#8217;t have more than two children.</p>



<p>Notice how the 59 has two children.</p>



<p>That&#8217;s fine.</p>



<p>If it was three, that&#8217;s way too much.</p>



<p>52 has one.</p>



<p>87 has one.</p>



<p>No, 87 has two children.</p>



<p>99 has one child.</p>



<p>92 has zero children.</p>



<p>So, okay, we&#8217;re not violating that rule.</p>



<p>So, we definitely have a binary tree.</p>



<p>And then we, you know, kind of read from left to right.</p>



<p>Let me write down the numbers this time for fun.</p>



<p>physically without kind of like following edges or anything we just scan</p>



<p>our eyes from left to right we can see that we have an ascending list if we</p>



<p>supported duplicates it would be okay to just see a non decreasing list but we</p>



<p>see an increasing list or an ascended list ascending list okay whoops this is</p>



<p>left to right so this is actually a binary search tree and um i don&#8217;t know about you but i think i</p>



<p>need to like you know get a snickers or something right now because uh this video has been going on</p>



<p>for longer than i wanted it to go on so we&#8217;ve defined a binary search tree in future videos</p>



<p>we&#8217;ll talk about how to add nodes into a binary search tree how to build the tree what&#8217;s the time</p>



<p>complexity of the tree in various operations deleting nodes from a tree terminology like</p>



<p>terminology like what are these nodes called things like that so anyway thank you so much</p>



<p>for for watching i hope you learned a little bit of stuff and had a little bit of fun</p>



<p>i&#8217;ll see you at a later date in time</p>



<p>just kidding</p>



<p>hey everybody thanks for watching this video again from the bottom of my heart i really</p>



<p>appreciate it i do hope you did learn something and have some fun uh if you could do me a please</p>



<p>If you could do me a please a small little favor</p>



<p>Could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media?</p>



<p>It&#8217;s a website that you&#8217;re looking at right now</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community</p>



<p>So we&#8217;ll be able to do more videos longer videos better videos or just i&#8217;ll be able to keep making videos in general</p>



<p>So please do do me a kindness and uh and subscribe</p>



<p>I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p>It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website,</p>



<p>which I think is also named somewhere at the bottom of this video.</p>



<p>and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p>I published and the services and tutorials and things that I offer and all that good</p>



<p>stuff.</p>



<p>And if you have a suggestion for clarifications or errata or just future videos that you want</p>



<p>to see, please leave a comment.</p>



<p>Or if you just want to say, Hey, what&#8217;s up?</p>



<p>What&#8217;s going on?</p>



<p>You know, just send me a comment, whatever.</p>



<p>I also wake up for those in the middle of the night.</p>



<p>I get, I wake up in a cold sweat and I&#8217;m like, it would really, it would really, it</p>



<p>it would really mean the world to me.</p>



<p>I would really appreciate it.</p>



<p>So again, thank you so much for watching this video</p>



<p>and enjoy the cool music</p>



<p>as I fade into the darkness,</p>



<p>which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-search-tree-definition-explained-step-by-step/">Binary Search Tree Definition Explained Step by Step</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/binary-search-tree-definition-explained-step-by-step/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
