 So the last search that I'll at least sort of introduce is sort of this idea of something being a Bidirectional search now the idea behind a bidirectional search is well, you know Again, I might have a starting point and I might have a goal condition Well the BFS again will get me there, but I have to do my moves one step at a time So it's a lot of branching out a lot of unnecessary Pathways that actually might not be really close to my goal So what bidirectional search is essentially doing is saying well One way we are going to solve this is when I do my starting point searches I'm also going to do my searches from the goal. I'm essentially taking steps back I know how to get to the goal from sort of any of the points around that goal And so I'm going to make one step with my search. I'm making these multiple steps I'm just not going to draw them all out and then I make that same sort of step and those multiple steps around goal All one step then when I branch out again, I make my next sort of steps I do my next sort of iteration With both of these so again starting goal are happening at the same time. I'm gonna make my next move I'm gonna make my next move. I'm gonna make my next move I'm gonna make my next move and what you're gonna notice is that if I keep on following sort of this path Or these two paths, I might reach a point Where I find a connection a node that Was in the starting path and in the goal path and well well since I've done, you know I see it in both of them. I Have found the path And okay to walk through this in a little bit or in our sense, you know again completeness. Yes Optimality. Yes, if we think about the idea of step cost being equal and we're doing specifically the breadth first more to the point though notice When we are dealing with sort of space and time complete complexity less then BFS DFS and iterative deepening search Actually by half and the reason behind this is very similar to if just to kind of see this Or explain this if I look at sort of oh of in versus Ovin cubed versus Ovin Squared they're both sort of going up at very high exponential rates. So here's the two and here's the three But you know one's just doing it at a much faster route What we're dealing with here is sort of that similar thing so in our sense even though again It may be a large number We are going to be able to cut that search in half by doing sort of two searches at the same time To walk through this again All we're doing is just two breadth first searches two cues are happening from my starting point and my goal point In this case, I'm working off of H. Again, you can see they both start from nothing We're gonna treat them both as if they are the starting point Well, again, I do my q1 my starting q and I treat it just like it's a breadth first search I see that it has B. It has C. It has I I'm adding them in you know alphabetical order just for the sake of kind of explainability not visual ability, but again, they're in the queue They are all sort of waiting to be processed But rather than sort of the next step of a queue or a BFS queue or we just decrement DQ the next move. We're actually gonna completely Move over and now we're gonna make a step with our second queue And so the same thing is going to happen. We removed H from the queue H has two possible routes f and g and so they're added to the queue. All right. Well now, what do we do? We go back to q1 and we just follow its queue B is the first thing in there. So we are going to remove it We see that B happens to have its own sort of child it can go to K So we add it to its queue You already know what's about to happen. I go back to queue number two and I am going to pull out my F And I'm gonna add in G and or J and E. I'm not gonna add in G again only because I see it in there, you know, that's a more of a design choice for our sake It's already in the queue. We'll leave it there Okay. Well, what happens next? Back to q1. I see that C is the next one in the route. I Remove it now one thing to sort of note just because G is in both of the queues. We are not done Being in the queue just means it's in line to get considered But it's not in our pathways again if we're thinking about this we have a pathway a to H and so yes We are sort of in this route of I see that C is going to get me there I see that G well not actually that's wrong G has not been added into the H pathway quite yet All I've seen is that a can go to C H Can go somewhere it can go to G So again, all I know right now is a can go to C and H can come from G I don't know that C can go to G Quite yet. Not there yet. And so that's actually sort of that point. Notice how K is sitting inside of my Both my queues as well Because what happens if K is in both pathways first that might be the faster route Again that it all depends on just where it's followed in the queue Both of them are gonna get me there and you notice they're both gonna be the optimal Well, one's gonna give me a Pathway of four one's gonna get me the pathway of three But we have to work through the algorithm to officially make that happen. So again, where am I so Q2? Alright, so adds C and K to it Q2 moves to no G. Okay, so I've just hit Q2. I'm going back. I'm going to look at I All right, well I does its song and dance it's gonna add the D You know, it's not that we already have it set in stone again We're just sort of waiting for that fact that we see G is in our our next step So or in our Q1 and once we do We have our pathway. So we have to work through the algorithm again. So I just got Removed we move back to Q. We are about to do this next same thing to E Once again, you see that we have a few possible routes in the queue for consideration Again, we're looking for a pathway from A to H. We're hopefully gonna get the most optimal route But it all takes walking through the algorithm to find that out. So again, we just worked off of E we come over to Start and we add Q Q is a possible route that a can get to so we do see again this idea that a can Go from these different pathways H Can let's see it had the possibility of going from F. It has the possibility of going to G But again, we have not sort of made that next hook and there's also I let me just add an I Real fast So again, you know, what's gonna happen? We go to J. J is gonna be consumed It's gonna be a possible pathway Right and we don't see any new paths from J. So it's Q We're just gonna leave it as is you could again still add the D It depends on the algorithm or how you're working through it, but finally I See that once again, I have a I have C I have H that's able to go to G and I see finally in my first Q that from C I can get to G. I see that C can make that leap of faith and Once I do I happen to know oh well since I Had the connection of ACG and I had the connection of H From G since G is in both of these pathways I have found the optimal solution in less time than breadth-first search By using bi-directional search