<?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>connected graph Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/connected-graph/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/connected-graph/</link>
	<description></description>
	<lastBuildDate>Sat, 25 Jul 2026 23:04:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>connected graph Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/connected-graph/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</title>
		<link>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/</link>
					<comments>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sat, 25 Jul 2026 23:04:51 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[connected graph]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[directed graph]]></category>
		<category><![CDATA[graph algorithms]]></category>
		<category><![CDATA[graph connectedness]]></category>
		<category><![CDATA[graph paths]]></category>
		<category><![CDATA[graph theory]]></category>
		<category><![CDATA[nodes and edges]]></category>
		<category><![CDATA[strongly connected graph]]></category>
		<category><![CDATA[subgraphs]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[weakly connected graph]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=417</guid>

					<description><![CDATA[<p>This video explains graph connectedness for both undirected and directed graphs. For undirected graphs a connected graph means every node can reach every other node through a path. Disconnected graphs have nodes that cannot reach others and may contain separate subgraphs. For directed graphs the terms change to strongly connected where every node reaches every other node following edge directions and weakly connected where the graph is connected if directions are ignored. Step by step examples show how adding edges turns a graph from not connected to weakly connected and finally to strongly connected.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/">Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</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="Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected" width="1380" height="776" src="https://www.youtube.com/embed/u1D6huK1DCA?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 class="wp-block-paragraph">Hello there. Lets talk about graphs and whether they are connected or not or maybe whether they are strongly connected versus weakly connected. We look at undirected graphs first and show what makes a graph connected meaning every node can reach every other node by a path. We add edges and check the connections step by step while also noting subgraphs. Then we switch to directed graphs and explain strongly connected versus weakly connected. Strongly connected follows the edge directions for every path. Weakly connected ignores the directions and checks if the graph would still be connected. Examples show how adding edges changes the status of the graph.</p>



<p class="wp-block-paragraph">00:00 Introduction to Graph Connectedness<br>00:01 Drawing Nodes and a Disconnected Graph<br>01:56 Defining a Connected Graph<br>03:21 Introducing Subgraphs<br>04:48 Adding Edges to Create a Connected Graph<br>06:32 Adding Directions to Create a Directed Graph<br>08:03 Strongly Connected Versus Weakly Connected<br>08:34 Removing an Edge to Show Disconnection<br>09:29 Checking and Achieving Weak Connectivity<br>11:18 Adding Edges to Create a Strongly Connected Graph<br>13:20 Confirming the Strongly Connected Graph<br>13:32 Conclusion<br>14:17 Outro and Subscribe Request</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">Hello there! Let&#8217;s talk about graphs and whether they&#8217;re connected or not or maybe whether they&#8217;re</p>



<p class="wp-block-paragraph">strongly connected versus weakly connected versus not connected. You never know.</p>



<p class="wp-block-paragraph">Okay, so hopefully you&#8217;ve seen my previous videos by now where we just talked about the basics of</p>



<p class="wp-block-paragraph">paper here i&#8217;m just going to start drawing a graph remember graphs are nodes and edges where</p>



<p class="wp-block-paragraph">the nodes are like little t-type data structures that can hold a specific type of value um so i&#8217;m</p>



<p class="wp-block-paragraph">going to say our our nodes hold integers um i think i made that one too small that&#8217;s okay</p>



<p class="wp-block-paragraph">and the edges uh could have weights or maybe not weights at all depending on if you have</p>



<p class="wp-block-paragraph">a weighted or an unweighted graph so i&#8217;m just going to start duplicating my nodes a little bit</p>



<p class="wp-block-paragraph">going to make a random graph. I need to probably change these values. Technically your graphs</p>



<p class="wp-block-paragraph">should support duplicate values in the nodes and also the weights, but I don&#8217;t want to because</p>



<p class="wp-block-paragraph">it&#8217;s easier to talk about the graph when all the values are distinct. So for starters, we have a</p>



<p class="wp-block-paragraph">bunch of nodes and they&#8217;re not really connected to each other. Is this a valid graph? Yeah it is.</p>



<p class="wp-block-paragraph">It&#8217;s just not a connected graph. So the terminology that we&#8217;re going to use for</p>



<p class="wp-block-paragraph">undirected graphs meaning the edges don&#8217;t have direction is going to be connected or not you</p>



<p class="wp-block-paragraph">know i usually just say a not connected graph or a disconnected graph so just basically like</p>



<p class="wp-block-paragraph">connected or not connected okay so this is a not connected graph i&#8217;m going to say not connected</p>



<p class="wp-block-paragraph">not cinnamon i&#8217;m thinking about food as usual</p>



<p class="wp-block-paragraph">connected graph why is it not a connected graph well to define what does it mean to be a connected</p>



<p class="wp-block-paragraph">graph it just means that every single node can find a path to every single other node</p>



<p class="wp-block-paragraph">in an undirected graph so we can just double check this real fast we can say you know can</p>



<p class="wp-block-paragraph">node number two find a path to uh you know let me put a question here let&#8217;s say we&#8217;re going to check</p>



<p class="wp-block-paragraph">you should be checking all the nodes one by one by one to see if if the node in particular can</p>



<p class="wp-block-paragraph">first node that can&#8217;t do it means the whole graph is not considered connected so you know two it</p>



<p class="wp-block-paragraph">can&#8217;t reach one so that means it&#8217;s not a connected graph so this is not a connected graph because one</p>



<p class="wp-block-paragraph">or more nodes violate the rule of you have to be able to reach every single other node okay so that</p>



<p class="wp-block-paragraph">means if we want a connected graph we probably just have to start adding edges so I&#8217;m going to</p>



<p class="wp-block-paragraph">go ahead and uh let me let me write the word connected here and then I can like either circle</p>



<p class="wp-block-paragraph">cross it out. So right now we have no, this is not a connected graph. I&#8217;m going to start adding</p>



<p class="wp-block-paragraph">edges. We&#8217;re going to stick with an undirected graph for now. So I&#8217;m going to connect two and one</p>



<p class="wp-block-paragraph">and two and nine, maybe one and 13. Actually, you know what? I&#8217;m going to erase this edge</p>



<p class="wp-block-paragraph">and maybe connect these over here. And the thing is, this is a valid graph that you&#8217;re looking at.</p>



<p class="wp-block-paragraph">it&#8217;s just not a connected graph.</p>



<p class="wp-block-paragraph">Some other terminology I didn&#8217;t mention in other videos</p>



<p class="wp-block-paragraph">is that we can have subgraphs.</p>



<p class="wp-block-paragraph">We have like a subgraph here and another subgraph here.</p>



<p class="wp-block-paragraph">Those are basically just two different portions of the same graph</p>



<p class="wp-block-paragraph">that appear to be connected within themselves.</p>



<p class="wp-block-paragraph">So those are subgraphs.</p>



<p class="wp-block-paragraph">You can probably tell right away that this is not a connected graph.</p>



<p class="wp-block-paragraph">You can double check to be sure.</p>



<p class="wp-block-paragraph">You know, it&#8217;s good to do things the hard way</p>



<p class="wp-block-paragraph">so you don&#8217;t get the wrong answer</p>



<p class="wp-block-paragraph">when you&#8217;re really trying to figure something out.</p>



<p class="wp-block-paragraph">So let&#8217;s look at two.</p>



<p class="wp-block-paragraph">So let&#8217;s look at two. Can two reach one? Yes. So that&#8217;s good. Can two reach nine? Yeah,</p>



<p class="wp-block-paragraph">it just hops to one and then hops to nine. So two can reach one and also nine. That&#8217;s good.</p>



<p class="wp-block-paragraph">Can two reach three? Nope. So this is still not a connected graph.</p>



<p class="wp-block-paragraph">Okay, I&#8217;m going to add one more edge. And then we&#8217;ll just check again.</p>



<p class="wp-block-paragraph">Where do you think I&#8217;m going to do it? Maybe if I add, I&#8217;ll add a funky edge going from 13 to like</p>



<p class="wp-block-paragraph">to like nine or something just so it feels a little bit more awkward okay let&#8217;s check one by</p>



<p class="wp-block-paragraph">one by one let me actually get rid of this edge on the previous slide so we can still say that&#8217;s</p>



<p class="wp-block-paragraph">not connected let&#8217;s check one by one by one every node must be able to reach every single other</p>



<p class="wp-block-paragraph">node so I&#8217;m gonna look at two and I&#8217;m gonna say all right two can it reach one yes can it reach</p>



<p class="wp-block-paragraph">to nine. So that&#8217;s good. Can it reach three? Yeah, it can go from two to one to nine to 13</p>



<p class="wp-block-paragraph">to three, and then it can reach three. And because we just saw that it went through 13 to reach three,</p>



<p class="wp-block-paragraph">that means two can reach every single other node. This is going to be more important as a double</p>



<p class="wp-block-paragraph">check when we have directed graphs in a second. So two is good. So the next thing you want to do is</p>



<p class="wp-block-paragraph">the next thing you want to do is just move on to some other node and do the exact same process you</p>



<p class="wp-block-paragraph">know can can nine reach a one yes okay it can reach a one can it reach a two yeah it goes through</p>



<p class="wp-block-paragraph">the one can it reach the 13 yep can it reach the three yep okay so we just check every single</p>



<p class="wp-block-paragraph">destination node starting at the node nine but here&#8217;s a little bit of a shortcut try to find a</p>



<p class="wp-block-paragraph">node that is right next to a node that you know can reach everything and if the node in question</p>



<p class="wp-block-paragraph">that previously connected node, vertex,</p>



<p class="wp-block-paragraph">then we know that that node in particular is also connected.</p>



<p class="wp-block-paragraph">So what I&#8217;m saying is the one,</p>



<p class="wp-block-paragraph">instead of checking every single other node in the graph,</p>



<p class="wp-block-paragraph">which might be really hard</p>



<p class="wp-block-paragraph">if we have a whole bunch of nodes in our graph,</p>



<p class="wp-block-paragraph">we&#8217;ll just ask, can the one reach the two?</p>



<p class="wp-block-paragraph">Because if it can, the two can reach everything.</p>



<p class="wp-block-paragraph">So that means the one actually can reach everything as well.</p>



<p class="wp-block-paragraph">So the one can reach the two.</p>



<p class="wp-block-paragraph">So the one is connected to everything.</p>



<p class="wp-block-paragraph">the three, the three can reach the one and the one can reach everything. I&#8217;m doing things the</p>



<p class="wp-block-paragraph">hard way on purpose just to prove a point. So the three can reach everything. The 13 can reach the</p>



<p class="wp-block-paragraph">three in one hop. So the 13 can reach everything. The nine, it can reach the one and it can reach</p>



<p class="wp-block-paragraph">the 13 in one hop. So the nine can also actually reach everything. So that means this is indeed a</p>



<p class="wp-block-paragraph">the next thing that we&#8217;re going to do is add direction to our graph you know we could do like</p>



<p class="wp-block-paragraph">more examples maybe leave a comment if you want me to do some super extra complicated examples for</p>



<p class="wp-block-paragraph">just a undirected and connected graph i&#8217;m ignoring weight by the way because it doesn&#8217;t really matter</p>



<p class="wp-block-paragraph">for these purposes so let&#8217;s upgrade our graph so uh maybe i should put a question mark here</p>



<p class="wp-block-paragraph">that would have been a good idea we&#8217;re just asking you know is it connected or not</p>



<p class="wp-block-paragraph">And I&#8217;m just going to start adding direction to every single edge.</p>



<p class="wp-block-paragraph">Let&#8217;s see if I&#8217;m following my notes.</p>



<p class="wp-block-paragraph">Single node, subgraphs, right?</p>



<p class="wp-block-paragraph">Well, it wasn&#8217;t connected at first and then we started adding.</p>



<p class="wp-block-paragraph">Okay, so that&#8217;s basically okay.</p>



<p class="wp-block-paragraph">Let&#8217;s add direction to every single edge.</p>



<p class="wp-block-paragraph">So every single edge has to have a direction</p>



<p class="wp-block-paragraph">or every single edge has to have no direction.</p>



<p class="wp-block-paragraph">You can&#8217;t really mix and match.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to go through every single edge and add a direction like this.</p>



<p class="wp-block-paragraph">and you know to be fair I think I&#8217;ve said this in my other videos an undirected edge is kind of the</p>



<p class="wp-block-paragraph">same thing as a directed edge going in or two directed edges going in both directions so this</p>



<p class="wp-block-paragraph">3 and 13 what&#8217;s going on with my computer hello this 3 and 13 edge it would have kind of been the</p>



<p class="wp-block-paragraph">same as just having two edges going in opposite directions so maybe I&#8217;ll just do that right now</p>



<p class="wp-block-paragraph">for this huge weird edge I&#8217;m just going to put like an arrow over here instead of totally redrawing</p>



<p class="wp-block-paragraph">Then I double check that every single edge has a direction so that I have a valid graph.</p>



<p class="wp-block-paragraph">And now I can ask, is this connected or not?</p>



<p class="wp-block-paragraph">Actually, when it comes to a directed graph, you don&#8217;t really have connected or not anymore.</p>



<p class="wp-block-paragraph">You have strongly connected versus weakly connected.</p>



<p class="wp-block-paragraph">Maybe I should just separate these words and then just kind of like move them.</p>



<p class="wp-block-paragraph">So let&#8217;s get rid of this.</p>



<p class="wp-block-paragraph">to this save this over here move it down so what am i talking about um well first let me remove an</p>



<p class="wp-block-paragraph">edge real quick i&#8217;ll remove this edge right here so now we have two sub graphs in this graph you</p>



<p class="wp-block-paragraph">can tell for sure if this was an undirected graph it would not be connected but now that we&#8217;re</p>



<p class="wp-block-paragraph">dealing with direction we have to ask is it strongly connected versus weakly so what does</p>



<p class="wp-block-paragraph">can every node reach every other node if you obey the direction of the edges so that&#8217;s clearly not</p>



<p class="wp-block-paragraph">true there&#8217;s no edge at all that even connects this one and nine so it&#8217;s definitely not strongly</p>



<p class="wp-block-paragraph">connected weakly connected on the other hand means if you temporarily ignore the direction</p>



<p class="wp-block-paragraph">of the edges then could you consider the graph connected so if we pretended that there were no</p>



<p class="wp-block-paragraph">arrows here would we think that it&#8217;s a connected graph if the answer is yes then it&#8217;s at least a</p>



<p class="wp-block-paragraph">So this is not weakly connected because if this was an undirected graph, it&#8217;s not even connected at all.</p>



<p class="wp-block-paragraph">So that sucks.</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and add another edge here.</p>



<p class="wp-block-paragraph">So I&#8217;m going to add an edge from 2 to 9.</p>



<p class="wp-block-paragraph">So the first thing is, oh, sorry, I have to add another edge.</p>



<p class="wp-block-paragraph">Let me do from 1 to 13 for fun.</p>



<p class="wp-block-paragraph">So now the first thing is, let&#8217;s check to see if this is a strongly connected graph.</p>



<p class="wp-block-paragraph">node is unreachable by any other node so this is definitely not strongly</p>



<p class="wp-block-paragraph">connected because all the other nodes would be would have to be able to reach</p>



<p class="wp-block-paragraph">too alright so first thing you could do just to very quickly check is just look</p>



<p class="wp-block-paragraph">at every single node and ask is it reachable you know by anything and then</p>



<p class="wp-block-paragraph">after that you can do things the hard way so it&#8217;s not strongly connected what</p>



<p class="wp-block-paragraph">about weakly connected if we ignore the direction of the graph sorry if we</p>



<p class="wp-block-paragraph">then yeah, we could reach every single node from every other node. Let&#8217;s just double check that</p>



<p class="wp-block-paragraph">real fast. I&#8217;m going to say, you know, the two node, if we&#8217;re ignoring direction, can it reach</p>



<p class="wp-block-paragraph">the one? Yes. Can it reach the 13? Yes. The three? Yes. Can it reach the nine? Yes. So that means the</p>



<p class="wp-block-paragraph">two node is sort of like weakly connected to every other node in the graph. Do the same thing for the</p>



<p class="wp-block-paragraph">one node. Previously, we just said, you know, check everything one by one or use a shortcut.</p>



<p class="wp-block-paragraph">one by one or use a shortcut. So I&#8217;m going to use the shortcut. The one node, if we ignore direction</p>



<p class="wp-block-paragraph">can reach the two nodes. So I&#8217;m going to say the one is weakly connected, at least everything else.</p>



<p class="wp-block-paragraph">I&#8217;m not even going to check to see if it&#8217;s strongly connected to everything else. I think the answer</p>



<p class="wp-block-paragraph">is no, but we do the same thing for the 13. The 13 can reach the one pretty fast. The three can</p>



<p class="wp-block-paragraph">reach the 13. The nine can reach the two. So every single node can weakly reach. That&#8217;s not an</p>



<p class="wp-block-paragraph">a weakly connected graph. Okay, cool. How can we make this a strongly connected graph? Well,</p>



<p class="wp-block-paragraph">we just have to add a bunch of edges. So that&#8217;s what I&#8217;m going to do. I&#8217;m going to kind of like</p>



<p class="wp-block-paragraph">look at what is missing here. So we&#8217;ll ask the two, can the two reach and let&#8217;s obey the direction</p>



<p class="wp-block-paragraph">of the edges again. Can the two reach the one? Yes. Can the two reach the 13? Yes. Can it reach</p>



<p class="wp-block-paragraph">Yes, so that means right now the two is strongly connected to everything else.</p>



<p class="wp-block-paragraph">So we&#8217;re on track for a strongly connected graph.</p>



<p class="wp-block-paragraph">We then look at the one node and we realize that the one node,</p>



<p class="wp-block-paragraph">it can reach the 13 and the three and it can also reach the nine,</p>



<p class="wp-block-paragraph">but it can&#8217;t reach the two.</p>



<p class="wp-block-paragraph">That&#8217;s one thing that was blocking us last time from saying strongly connected.</p>



<p class="wp-block-paragraph">So we just have to add another edge if we want this to be a strongly connected graph.</p>



<p class="wp-block-paragraph">We have to figure out how can we get the one to reach the two.</p>



<p class="wp-block-paragraph">the 2 we can go through something if we want to that&#8217;s fine we can also just</p>



<p class="wp-block-paragraph">write an edge that just goes back to the 2 but that&#8217;s I don&#8217;t know that&#8217;s kind of</p>



<p class="wp-block-paragraph">boring I&#8217;m gonna make an edge that goes from 1 to 9 and then I&#8217;m gonna make an</p>



<p class="wp-block-paragraph">edge that goes from 9 to 2 so looking at the 1 node it can now reach the 2 if we</p>



<p class="wp-block-paragraph">go through the 9 so that&#8217;s good can the 1 reach the 9 yes can the 1 reach the 13</p>



<p class="wp-block-paragraph">three yes okay so the one node can now reach every single other node so now we&#8217;re a little bit more</p>



<p class="wp-block-paragraph">on track for a strongly connected graph look at the 13 node can it reach the one node um actually</p>



<p class="wp-block-paragraph">yes if we go from 13 to 9 and then 2 and then 1 we can reach the one node since we know the one</p>



<p class="wp-block-paragraph">node is connected to everything else we can now say that the 13 node is connected to everything</p>



<p class="wp-block-paragraph">13 so i&#8217;ll say three is connected to everything the nine node can reach the two node which is</p>



<p class="wp-block-paragraph">connected to everything so that means the nine node is also connected to everything and at this</p>



<p class="wp-block-paragraph">point we now have a strongly connected graph it&#8217;s not weakly connected it&#8217;s stronger than that</p>



<p class="wp-block-paragraph">any questions um so let&#8217;s see we added a bunch of uh edges i think maybe this is actually all we</p>



<p class="wp-block-paragraph">need to do for this particular video because we&#8217;re just going to talk about connectedness</p>



<p class="wp-block-paragraph">going to talk about connectedness about 15 minutes not too bad all right so i think i&#8217;m</p>



<p class="wp-block-paragraph">going to leave it here drop a comment if you want to do way more complicated examples if you want to</p>



<p class="wp-block-paragraph">provide me a sample graph that&#8217;s awful and i could just i don&#8217;t know in the sometime in the future i</p>



<p class="wp-block-paragraph">could record a video about it um or just let me know your thoughts thank you so much for watching</p>



<p class="wp-block-paragraph">this video i hope you had a little bit of fun and i hope you learned a little bit of stuff i&#8217;m outie</p>



<p class="wp-block-paragraph">Patowdy.</p>



<p class="wp-block-paragraph">Alright, let&#8217;s see.</p>



<p class="wp-block-paragraph">I&#8217;m going to do this.</p>



<p class="wp-block-paragraph">Whoa. Can you see that guy in the background?</p>



<p class="wp-block-paragraph">Oh, shoot.</p>



<p class="wp-block-paragraph">I&#8217;m just kidding.</p>



<p class="wp-block-paragraph">I set that as the screensaver.</p>



<p class="wp-block-paragraph">Hey, everybody.</p>



<p class="wp-block-paragraph">Thanks for watching this video again from the bottom of my heart.</p>



<p class="wp-block-paragraph">I really appreciate it.</p>



<p class="wp-block-paragraph">I do hope you did learn something and have some fun.</p>



<p class="wp-block-paragraph">If you could do me a please, a small little favor,</p>



<p class="wp-block-paragraph">please subscribe and follow this channel or these videos or whatever it is you do on the current</p>



<p class="wp-block-paragraph">social media website that you&#8217;re looking at right now. It would really mean the world to me and it&#8217;ll</p>



<p class="wp-block-paragraph">help make more videos and grow this community. So we&#8217;ll be able to do more videos, longer videos,</p>



<p class="wp-block-paragraph">better videos, or just I&#8217;ll be able to keep making videos in general. So please do me a kindness</p>



<p class="wp-block-paragraph">and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up</p>



<p class="wp-block-paragraph">or followed. It just wakes me up and I get filled with joy. That&#8217;s exactly what happens every single</p>



<p class="wp-block-paragraph">time. So you could do it as a nice favor to me or you could you could troll me if you want to just</p>



<p class="wp-block-paragraph">wake me up in the middle of the night. Just subscribe and then I&#8217;ll just wake up. I promise</p>



<p class="wp-block-paragraph">that&#8217;s what will happen. Also if you look at the middle of the screen right now you should see a</p>



<p class="wp-block-paragraph">QR code which you can scan in order to go to the website which I think is also named somewhere at</p>



<p class="wp-block-paragraph">the bottom of this video and it&#8217;ll take you to my main website where you can just kind of like see</p>



<p class="wp-block-paragraph">videos i published and the services and tutorials and things that i offer and all that good stuff</p>



<p class="wp-block-paragraph">and uh if you have a suggestion for uh uh clarifications or errata or just future videos</p>



<p class="wp-block-paragraph">that you want to see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on</p>



<p class="wp-block-paragraph">you know just send me a comment whatever i also wake up for those in the middle of the night i get</p>



<p class="wp-block-paragraph">i 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 class="wp-block-paragraph">it so again thank you so much for watching this video and enjoy the cool</p>



<p class="wp-block-paragraph">music as as I fade into the darkness which is coming for us all</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and get started.</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">Yeah, I think I&#8217;m good.</p>



<p class="wp-block-paragraph">Hello there.</p>



<p class="wp-block-paragraph">Let&#8217;s talk about whether a graph is connected or not,</p>



<p class="wp-block-paragraph">or maybe whether it&#8217;s strongly connected or weakly connected or not connected at all.</p>



<p class="wp-block-paragraph">You never know.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/">Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/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 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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">hey there let&#8217;s talk about binary search trees specifically in this video I want to help you</p>



<p class="wp-block-paragraph">define and identify what is a binary search tree all the rules that go into determining whether</p>



<p class="wp-block-paragraph">or not something is a binary search tree so you can you can tell that you&#8217;re looking at one or</p>



<p class="wp-block-paragraph">whether you&#8217;re not looking at one we&#8217;ll talk about some terminology but keep in mind I&#8217;m</p>



<p class="wp-block-paragraph">going to save searching and sorting and like you know deleting and adding items and a whole bunch</p>



<p class="wp-block-paragraph">extra stuff, especially the hard stuff for videos that&#8217;ll come right after this one.</p>



<p class="wp-block-paragraph">For now, we&#8217;re just going to talk about what is a binary search tree.</p>



<p class="wp-block-paragraph">So you can see on the screen right here, I hope that we have a binary search tree.</p>



<p class="wp-block-paragraph">Let&#8217;s see.</p>



<p class="wp-block-paragraph">Can you see that?</p>



<p class="wp-block-paragraph">Yeah, I think you probably can.</p>



<p class="wp-block-paragraph">Yeah, I think you can.</p>



<p class="wp-block-paragraph">This is not drawn quite as well as I would like to draw ours.</p>



<p class="wp-block-paragraph">I&#8217;ll tell you how to do that in a little while.</p>



<p class="wp-block-paragraph">to do that in a little while but when you draw a tree in a really really nice pretty aligned way</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">uh i guess i can probably expect that you already kind of know what a graph is at this point in time</p>



<p class="wp-block-paragraph">and edges. So what do I mean by nodes? Well just imagine there&#8217;s like a little circle here</p>



<p class="wp-block-paragraph">that contains some sort of data. If you know data structures already then</p>



<p class="wp-block-paragraph">there would be a t-type sitting inside the node. We&#8217;ll just call the t-type an integer</p>



<p class="wp-block-paragraph">and so for our nodes, for our trees, we&#8217;re just going to say that they hold integers even though</p>



<p class="wp-block-paragraph">you know technically speaking in a binary search tree or a graph you could have all sorts of</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">I&#8217;m just going to make a bunch of duplicates. Something is definitely wonky about my setup right now.</p>



<p class="wp-block-paragraph">I think I just upgraded the camera and the CPU is maxed out. I just upgraded the CPU on this computer too.</p>



<p class="wp-block-paragraph">Oh well. Okay. So we aren&#8217;t going to support duplicate values in our binary search tree,</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">no duplicate data. For now, I think I can probably do that somewhat quickly. Let&#8217;s see. So a graph,</p>



<p class="wp-block-paragraph">you know, for the for our purposes right now, a graph is just basically a collection of nodes and</p>



<p class="wp-block-paragraph">edges. It could be empty. It could be just nodes. It couldn&#8217;t just be edges, it would have an edge</p>



<p class="wp-block-paragraph">always has to have a node or two connected to it. So we just have like a bunch of nodes inside of</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">to do this it doesn&#8217;t really matter I&#8217;m just randomly drawing edges okay actually I should</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">What is a connected graph? A connected graph is basically a graph where every single node can find every single other node</p>



<p class="wp-block-paragraph">or find a path to every single other node only following along edges and only by respecting the direction of edges.</p>



<p class="wp-block-paragraph">You can see this particular graph is undirected meaning the edges don&#8217;t really have a direction to them.</p>



<p class="wp-block-paragraph">So that means we could travel along in any direction from node to node.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">But it cannot find a path to 99, which means this is not a connected graph.</p>



<p class="wp-block-paragraph">So that&#8217;s the first rule that we have to implement here.</p>



<p class="wp-block-paragraph">We&#8217;re going to say this graph needs to be upgraded or modified so that it will be a connected graph.</p>



<p class="wp-block-paragraph">start randomly adding edges until this is a connected graph I&#8217;m gonna do maybe</p>



<p class="wp-block-paragraph">like an edge from 99 to 12 there and then now I think this is a connected</p>



<p class="wp-block-paragraph">graph but let&#8217;s double check real fast so connected graph you know what I&#8217;m</p>



<p class="wp-block-paragraph">gonna put graph connectedness in another video to keep this one short for now</p>



<p class="wp-block-paragraph">check out my other videos if you would like to see whether or not a graph is</p>



<p class="wp-block-paragraph">but long story short as I just said if every single node can find a path to</p>



<p class="wp-block-paragraph">every single other node without you know skipping where there is no edge then</p>



<p class="wp-block-paragraph">it&#8217;s connected okay so that&#8217;s the first thing the next thing that we need let me</p>



<p class="wp-block-paragraph">just put the words connected up here we need a connected graph the next thing</p>



<p class="wp-block-paragraph">that we need is we need an acyclic graph which basically means a graph with no</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">So for example, if I was asking, you know, is 76 involved in any cycles?</p>



<p class="wp-block-paragraph">Well, we could go from 76 to 33 and then 12.</p>



<p class="wp-block-paragraph">And, you know, we could kind of take 8, 45, 12 again.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">so that means the 76 is not involved in any cycles because we cannot find our way back to 76</p>



<p class="wp-block-paragraph">without repeating an edge so 76 is okay i&#8217;m just going to maybe put like a little check box here</p>



<p class="wp-block-paragraph">and uh you can also tell that the 33 is not involved in any cycles because we go down to</p>



<p class="wp-block-paragraph">the 76 and then come back up to 33 we already repeated an edge so that&#8217;s not valid same thing</p>



<p class="wp-block-paragraph">again. Same thing for the 34, same thing for the 99. But if you look at the 12 here, we could</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">the eight to the 45 connection. See if that works. Um, let&#8217;s see. Well, wait a minute. What did I</p>



<p class="wp-block-paragraph">just do? Something happened here. I just accidentally, oh, I erased too many edges</p>



<p class="wp-block-paragraph">from the last slide. Okay. Let me add that one back in 33 to 76. That was supposed to be there.</p>



<p class="wp-block-paragraph">33 to 76 that was supposed to be there.</p>



<p class="wp-block-paragraph">So now we have an acyclic graph</p>



<p class="wp-block-paragraph">and we can consider this graph a tree.</p>



<p class="wp-block-paragraph">The next thing we need to do is add a hierarchy to this tree.</p>



<p class="wp-block-paragraph">So this is gonna make more sense in a little bit</p>



<p class="wp-block-paragraph">but for now I&#8217;m gonna say,</p>



<p class="wp-block-paragraph">we&#8217;ll imagine a family tree kind of,</p>



<p class="wp-block-paragraph">it&#8217;s not really exactly a family tree</p>



<p class="wp-block-paragraph">but you know imagine there are parents</p>



<p class="wp-block-paragraph">and children and grandchildren</p>



<p class="wp-block-paragraph">and we&#8217;ll just try to like,</p>



<p class="wp-block-paragraph">we&#8217;ll try to rank children according to</p>



<p class="wp-block-paragraph">according to you know when they were born or or how many parents or children</p>



<p class="wp-block-paragraph">they have you know their descendancy their lineage whatever you want to call</p>



<p class="wp-block-paragraph">it so I think I&#8217;m just gonna maybe move the eight up a little bit so that it&#8217;s</p>



<p class="wp-block-paragraph">on the same rank with the 12 and the 33 so I&#8217;m just gonna move these up a little</p>



<p class="wp-block-paragraph">bit and then redo their connecting lines so I&#8217;m gonna do this and that and then</p>



<p class="wp-block-paragraph">and then we&#8217;ll say that the 76 is still a child of the 33.</p>



<p class="wp-block-paragraph">So I&#8217;ll just kind of move it over here.</p>



<p class="wp-block-paragraph">Or sorry, we never said it was a child.</p>



<p class="wp-block-paragraph">Now we&#8217;re saying it&#8217;s a child</p>



<p class="wp-block-paragraph">because when you go from top to bottom,</p>



<p class="wp-block-paragraph">imagine like a family tree,</p>



<p class="wp-block-paragraph">we&#8217;ll say we have parents and children.</p>



<p class="wp-block-paragraph">The children or the descendants are lower.</p>



<p class="wp-block-paragraph">The ancestors or the parents or the grandparents are higher.</p>



<p class="wp-block-paragraph">Maybe I want to put this 45 over on the left</p>



<p class="wp-block-paragraph">so that it&#8217;s a child of the 8 node.</p>



<p class="wp-block-paragraph">And maybe I&#8217;ll say that the 99 node</p>



<p class="wp-block-paragraph">the 99 node is a child of the 12 node. Okay, so eventually this is going to look not exactly like</p>



<p class="wp-block-paragraph">a family tree because usually in the family tree we have two parents that go to one or more children.</p>



<p class="wp-block-paragraph">In this type of tree, in eventually our binary tree, we&#8217;re going to have one parent that has,</p>



<p class="wp-block-paragraph">you know, children just by itself, like asexual reproduction. We&#8217;re pretending to be bacteria</p>



<p class="wp-block-paragraph">What was that comedy skit a long time ago, Tiny Elvis?</p>



<p class="wp-block-paragraph">And he was like, hey, see that protozoa over there?</p>



<p class="wp-block-paragraph">The thing is huge.</p>



<p class="wp-block-paragraph">Anyone?</p>



<p class="wp-block-paragraph">No?</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So the next rule we need is we must have a rooted tree.</p>



<p class="wp-block-paragraph">What is a rooted tree?</p>



<p class="wp-block-paragraph">Actually, let me clean up the lineage real fast, the heritage.</p>



<p class="wp-block-paragraph">I want to make nodes that have the same level with respect to their ancestors</p>



<p class="wp-block-paragraph">respect to their ancestors to have the same physical y coordinate the same</p>



<p class="wp-block-paragraph">physical level so notice how the 99 I just moved it down a little bit because</p>



<p class="wp-block-paragraph">I wanted it to look like it&#8217;s the same you know number of generations lower</p>



<p class="wp-block-paragraph">than the top row so like with aid it had a child 45 so that&#8217;s one level down 33</p>



<p class="wp-block-paragraph">had a child that&#8217;s one level down that&#8217;s a 76 and the 12 also one level down</p>



<p class="wp-block-paragraph">would have been 99 but the 99 was kind of too physically high this will help</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">and uh now that we have you know parent child relationships we need to look at the most common</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">the word ancestor without explaining it so your ancestors are the people that you&#8217;re disappointing</p>



<p class="wp-block-paragraph">or whatever it is, ancestors came before us, right?</p>



<p class="wp-block-paragraph">Like my parents are my ancestors.</p>



<p class="wp-block-paragraph">My grandparents are also my ancestors.</p>



<p class="wp-block-paragraph">My great-grandparents are also my ancestors.</p>



<p class="wp-block-paragraph">Going down in the family tree are your descendants.</p>



<p class="wp-block-paragraph">You know, my children are my descendants.</p>



<p class="wp-block-paragraph">My grandchildren are my descendants.</p>



<p class="wp-block-paragraph">My great-grandchildren are my descendants and so forth.</p>



<p class="wp-block-paragraph">So if you look at the number 34 here,</p>



<p class="wp-block-paragraph">what is the greatest ancestor that it has?</p>



<p class="wp-block-paragraph">Well, if you just go up and up and up</p>



<p class="wp-block-paragraph">until you can&#8217;t go up anymore,</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">siblings there&#8217;s not really like a parent-child relationship they&#8217;re connected sideways we&#8217;ll</p>



<p class="wp-block-paragraph">eventually get rid of the sideways connections for our binary search trees but for now we have</p>



<p class="wp-block-paragraph">some siblings and so we actually have three different greatest ancestors in this tree we&#8217;ve</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">one common ancestor for every single other node in the entire tree so I&#8217;m going to duplicate this</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">the 76 on the same y coordinate the same level now we have two uh you know greatest ancestors</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">okay okay</p>



<p class="wp-block-paragraph">okay and then i have to get rid of that little sibling line and then i have to add another line</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">unrooted tree or just like not a rooted tree because there was no root there was no greatest</p>



<p class="wp-block-paragraph">greatest common ancestor to the entire rest of the tree. But now we can say that 12 is the root</p>



<p class="wp-block-paragraph">of the tree because it&#8217;s the ancestor for all other nodes. I guess even if 12 was by itself,</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">get rid of the word acyclic here since we already handled that. And I&#8217;m going to do,</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">have a rooted tree maybe I should type in my doomed I really hope the screen I really hope</p>



<p class="wp-block-paragraph">the screen cast doesn&#8217;t freeze it probably will upgraded the CPU it&#8217;s 33 faster than it was before</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">like 500 okay uh so the next rule is so we have a rooted tree and now let&#8217;s rearrange everything</p>



<p class="wp-block-paragraph">hierarchically which we already kind of did so uh there&#8217;s not really much to do here except</p>



<p class="wp-block-paragraph">we did hierarchical organization</p>



<p class="wp-block-paragraph">we probably just need to move on to our next rule which is to say that</p>



<p class="wp-block-paragraph">if our rooted tree is to become a binary tree</p>



<p class="wp-block-paragraph">then each node in the entire tree</p>



<p class="wp-block-paragraph">cannot have more than two children</p>



<p class="wp-block-paragraph">every single node in the entire tree</p>



<p class="wp-block-paragraph">can have zero or one or two children</p>



<p class="wp-block-paragraph">if there are three or more anywhere in the entire tree</p>



<p class="wp-block-paragraph">then it&#8217;s not a binary tree</p>



<p class="wp-block-paragraph">so okay that means you know the 45 is okay</p>



<p class="wp-block-paragraph">because it has no children</p>



<p class="wp-block-paragraph">because it has no children. All the rows, all the leaves at the bottom are okay. All these nodes</p>



<p class="wp-block-paragraph">over here are okay because they just have one child. But the 12 node, the root of the tree,</p>



<p class="wp-block-paragraph">it&#8217;s got three children and that violates the rule. So now we need to rearrange this.</p>



<p class="wp-block-paragraph">So I think I&#8217;m going to just move these numbers down here maybe. Whoops. Maybe move these nodes</p>



<p class="wp-block-paragraph">descendants of the 33 node. So I&#8217;m going to do this.</p>



<p class="wp-block-paragraph">Okay. So cool. Now we have a binary tree and now we need to rearrange the drawing a little bit.</p>



<p class="wp-block-paragraph">This is not part of the definition, but this will make it easier to debug your trees. So what I want</p>



<p class="wp-block-paragraph">to do is make it so that every left descendant of a node appears physically on that node&#8217;s left</p>



<p class="wp-block-paragraph">every right descendant of a node should appear on its right side</p>



<p class="wp-block-paragraph">or like further to the right on the x-coordinate</p>



<p class="wp-block-paragraph">so sort of similar to you know like the y-coordinate ranking</p>



<p class="wp-block-paragraph">but notice how the 12 its left child is 8 and its right child is 33</p>



<p class="wp-block-paragraph">so that means all the nodes here on the left side you know that come underneath the 8</p>



<p class="wp-block-paragraph">are left descendants or you could say that they are in the left subtree of the 12.</p>



<p class="wp-block-paragraph">So, they&#8217;re okay because 8 is to the left of 12 and 45 is to the left of 12.</p>



<p class="wp-block-paragraph">But notice how 33 is a right child of 12 and it&#8217;s part of the right subtree.</p>



<p class="wp-block-paragraph">It&#8217;s part of the right descendancy, but it&#8217;s physically on the left of 12.</p>



<p class="wp-block-paragraph">That&#8217;s going to be really bad because it&#8217;ll be harder to debug our trees later.</p>



<p class="wp-block-paragraph">So, I&#8217;m just going to slide it over without rearranging the tree.</p>



<p class="wp-block-paragraph">And I usually try to split the difference here.</p>



<p class="wp-block-paragraph">and then their parent is kind of like physically in the middle that will also help you debug in</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">right probably the 33 I think it&#8217;s still a little lopsided I probably could have you know dragged</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">It&#8217;s part of the right subtree of 33.</p>



<p class="wp-block-paragraph">It&#8217;s part of the right descendancy.</p>



<p class="wp-block-paragraph">And it should also be on the left side of the 99</p>



<p class="wp-block-paragraph">because it&#8217;s part of the left subtree of the 99.</p>



<p class="wp-block-paragraph">So, so far, this is okay.</p>



<p class="wp-block-paragraph">This is not the best drawing.</p>



<p class="wp-block-paragraph">So now we have a binary tree</p>



<p class="wp-block-paragraph">and we have kind of drawn it in a slightly good way.</p>



<p class="wp-block-paragraph">Not super great.</p>



<p class="wp-block-paragraph">The last rule that we&#8217;re going to add here is,</p>



<p class="wp-block-paragraph">whoops, what happened there?</p>



<p class="wp-block-paragraph">I&#8217;m supposed to do that, yeah.</p>



<p class="wp-block-paragraph">The last rule we&#8217;re going to add is</p>



<p class="wp-block-paragraph">we must have ordering to our nodes, to the numbers in our nodes. So what do I mean by ordering? Well,</p>



<p class="wp-block-paragraph">the whole reason that we want a binary search tree, at least usually, is because it&#8217;s really,</p>



<p class="wp-block-paragraph">really fast to search through. This is going to be a tree that we can search through in log time,</p>



<p class="wp-block-paragraph">which we&#8217;ll talk more about in another video. We&#8217;ll do time complexities and searching and stuff. But</p>



<p class="wp-block-paragraph">in order for this to be a super fast tree to search through, we need to be able to</p>



<p class="wp-block-paragraph">very quickly make a decision. Do we go down and to the left? Do we go down and to the right?</p>



<p class="wp-block-paragraph">left do we go down into the right and every decision we make should help us eliminate half</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">value than that particular node every node that is on the right side of a node meaning it&#8217;s a right</p>



<p class="wp-block-paragraph">descendant of that node or part of the right subtree of the node should be greater than that</p>



<p class="wp-block-paragraph">node. Please note that this would not allow us to support duplicate values in our tree.</p>



<p class="wp-block-paragraph">You could use something like less than or equal to versus greater than if you wanted to support</p>



<p class="wp-block-paragraph">duplicate values in your tree. You could also change the T type, you know, the template type</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">and the items in the list are just, you know, the regular values that you wanted. There&#8217;s a whole</p>



<p class="wp-block-paragraph">values that you wanted there&#8217;s a whole bunch of different ways you could actually do that</p>



<p class="wp-block-paragraph">but for now we&#8217;re going to see our trees don&#8217;t support duplicate values</p>



<p class="wp-block-paragraph">so okay we don&#8217;t support duplicate values but we need you know from left to right</p>



<p class="wp-block-paragraph">the order needs to look sane and this is kind of why we&#8217;re drawing the tree in this special way</p>



<p class="wp-block-paragraph">we&#8217;re trying to make our tree really easy to debug visually so check this out the way we&#8217;ve</p>



<p class="wp-block-paragraph">drawn this every single node has its own x coordinate basically notice how the 12 there&#8217;s</p>



<p class="wp-block-paragraph">nothing underneath it at least not directly underneath it the 33 the 34 all the nodes you</p>



<p class="wp-block-paragraph">know you can draw a straight line down from the node and it shouldn&#8217;t cross over with any other</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">descendants are on the left and all the right descendants are on the right we could actually</p>



<p class="wp-block-paragraph">just scan our eyes from left to right and be sure that we are seeing an increasing order or</p>



<p class="wp-block-paragraph">Since duplicates aren&#8217;t allowed in this tree, we&#8217;ll say an increasing order or an ascending order.</p>



<p class="wp-block-paragraph">So if we start at 45 and then we go to the right, we should see a higher number.</p>



<p class="wp-block-paragraph">So if we look at 8, 8 is a lower number.</p>



<p class="wp-block-paragraph">So this violates the ordering rule.</p>



<p class="wp-block-paragraph">This is not a valid binary search tree.</p>



<p class="wp-block-paragraph">It&#8217;s only a valid binary tree.</p>



<p class="wp-block-paragraph">So sad.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">we go to the right, we see another number here. It is 76. That already is increased from 59.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">There&#8217;s nodes and edges.</p>



<p class="wp-block-paragraph">There&#8217;s nothing weird happening.</p>



<p class="wp-block-paragraph">There&#8217;s not like a edge floating in the middle of nowhere.</p>



<p class="wp-block-paragraph">Is this a connected graph?</p>



<p class="wp-block-paragraph">Yeah, it is.</p>



<p class="wp-block-paragraph">Because every single node, if you followed, you know, the edges, you know, could find</p>



<p class="wp-block-paragraph">every single other node.</p>



<p class="wp-block-paragraph">Like the 45, it could find, you know, the 92 node if it just followed all these edges.</p>



<p class="wp-block-paragraph">Notice again that these edges have no direction.</p>



<p class="wp-block-paragraph">There&#8217;s no arrows on them.</p>



<p class="wp-block-paragraph">So we could go up or down in any direction we want.</p>



<p class="wp-block-paragraph">So that means the 76 can find everything else.</p>



<p class="wp-block-paragraph">else and so this is a connected graph for sure okay now that we have a</p>



<p class="wp-block-paragraph">connected graph is this an acyclic graph I don&#8217;t know about you but I can&#8217;t find</p>



<p class="wp-block-paragraph">any cycles in the graph right like the 92 it goes out but it doesn&#8217;t come back in</p>



<p class="wp-block-paragraph">same thing for the 76 if we went from the 76 up to the 87 and then took a</p>



<p class="wp-block-paragraph">right turn we wouldn&#8217;t be able to come back towards it without repeating that</p>



<p class="wp-block-paragraph">same edge so this is definitely an acyclic graph all of the nodes follow</p>



<p class="wp-block-paragraph">they&#8217;re not involved in cycles is this a rooted tree yeah there&#8217;s only one common ancestor to the</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">we arranged it hierarchically and we added the terminology of like i think i kind of just like</p>



<p class="wp-block-paragraph">tried to sneak this one past you but we added the terminology of a left child and a right child</p>



<p class="wp-block-paragraph">and a right child.</p>



<p class="wp-block-paragraph">Right? We also added the terminology of a right subtree and a left subtree.</p>



<p class="wp-block-paragraph">Just to clarify what I mean, what do I mean by a right subtree and a left subtree.</p>



<p class="wp-block-paragraph">So imagine we&#8217;re considering the 59.</p>



<p class="wp-block-paragraph">If we consider the 59, then the 52 is the root node of the left subtree of the 59 node.</p>



<p class="wp-block-paragraph">If we consider the 59, then the 87 is the root node of the right subtree of the 59 node.</p>



<p class="wp-block-paragraph">so the right child is basically the root of the subtree uh in in you know the right child is the</p>



<p class="wp-block-paragraph">root of a subtree of the right subtree uh i think i&#8217;m getting muddled my words here okay</p>



<p class="wp-block-paragraph">anyway so we have a little bit of terminology uh the 59 is the root node that&#8217;s like the</p>



<p class="wp-block-paragraph">the only node in the entire tree without uh an ancestor or a parent so okay uh then we have a</p>



<p class="wp-block-paragraph">Note, and the entire tree doesn&#8217;t have more than two children.</p>



<p class="wp-block-paragraph">Notice how the 59 has two children.</p>



<p class="wp-block-paragraph">That&#8217;s fine.</p>



<p class="wp-block-paragraph">If it was three, that&#8217;s way too much.</p>



<p class="wp-block-paragraph">52 has one.</p>



<p class="wp-block-paragraph">87 has one.</p>



<p class="wp-block-paragraph">No, 87 has two children.</p>



<p class="wp-block-paragraph">99 has one child.</p>



<p class="wp-block-paragraph">92 has zero children.</p>



<p class="wp-block-paragraph">So, okay, we&#8217;re not violating that rule.</p>



<p class="wp-block-paragraph">So, we definitely have a binary tree.</p>



<p class="wp-block-paragraph">And then we, you know, kind of read from left to right.</p>



<p class="wp-block-paragraph">Let me write down the numbers this time for fun.</p>



<p class="wp-block-paragraph">physically without kind of like following edges or anything we just scan</p>



<p class="wp-block-paragraph">our eyes from left to right we can see that we have an ascending list if we</p>



<p class="wp-block-paragraph">supported duplicates it would be okay to just see a non decreasing list but we</p>



<p class="wp-block-paragraph">see an increasing list or an ascended list ascending list okay whoops this is</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">need to like you know get a snickers or something right now because uh this video has been going on</p>



<p class="wp-block-paragraph">for longer than i wanted it to go on so we&#8217;ve defined a binary search tree in future videos</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">complexity of the tree in various operations deleting nodes from a tree terminology like</p>



<p class="wp-block-paragraph">terminology like what are these nodes called things like that so anyway thank you so much</p>



<p class="wp-block-paragraph">for for watching i hope you learned a little bit of stuff and had a little bit of fun</p>



<p class="wp-block-paragraph">i&#8217;ll see you at a later date in time</p>



<p class="wp-block-paragraph">just kidding</p>



<p class="wp-block-paragraph">hey everybody thanks for watching this video again from the bottom of my heart i really</p>



<p class="wp-block-paragraph">appreciate it i do hope you did learn something and have some fun uh if you could do me a please</p>



<p class="wp-block-paragraph">If you could do me a please a small little favor</p>



<p class="wp-block-paragraph">Could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media?</p>



<p class="wp-block-paragraph">It&#8217;s a website that you&#8217;re looking at right now</p>



<p class="wp-block-paragraph">It would really mean the world to me and it&#8217;ll help make more videos and grow this community</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">So please do do me a kindness and uh and subscribe</p>



<p class="wp-block-paragraph">I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p class="wp-block-paragraph">It just wakes me up and I get filled with joy.</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">Just subscribe and then I&#8217;ll just wake up.</p>



<p class="wp-block-paragraph">I promise that&#8217;s what will happen.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">which I think is also named somewhere at the bottom of this video.</p>



<p class="wp-block-paragraph">and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p class="wp-block-paragraph">I published and the services and tutorials and things that I offer and all that good</p>



<p class="wp-block-paragraph">stuff.</p>



<p class="wp-block-paragraph">And if you have a suggestion for clarifications or errata or just future videos that you want</p>



<p class="wp-block-paragraph">to see, please leave a comment.</p>



<p class="wp-block-paragraph">Or if you just want to say, Hey, what&#8217;s up?</p>



<p class="wp-block-paragraph">What&#8217;s going on?</p>



<p class="wp-block-paragraph">You know, just send me a comment, whatever.</p>



<p class="wp-block-paragraph">I also wake up for those in the middle of the night.</p>



<p class="wp-block-paragraph">I get, I wake up in a cold sweat and I&#8217;m like, it would really, it would really, it</p>



<p class="wp-block-paragraph">it would really mean the world to me.</p>



<p class="wp-block-paragraph">I would really appreciate it.</p>



<p class="wp-block-paragraph">So again, thank you so much for watching this video</p>



<p class="wp-block-paragraph">and enjoy the cool music</p>



<p class="wp-block-paragraph">as I fade into the darkness,</p>



<p class="wp-block-paragraph">which is coming for us all.</p>



<p class="wp-block-paragraph">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>
