BFS - Breadth First Search Algorithm Explained Visually (with examples)

preview_player
Показать описание
I'm a visual learner and I learned BFS visually first, which helped a lot with actually coding it.

In this video we go over:
- What is BFS
- What is the difference between Breadth First Search and Depth First Search .... Bfs vs Dfs
- What does the pseudo code look like?
- What data structures are used in BFS?
- The easiest application of BFS, finding whether or not you can go from one node to another in a graph
- What an example of BFS using a directed graph looks like

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

SUPER HELPFUL. I'm cramming for my test next week and this was one of the best video resources that I found so far.

AceyyMM
Автор

yeah such a good resource for learning about algorithms without going through a dense textbook, thank you for this

kevinma
Автор

Thank you very much for this! The quality of teaching is brilliant and you made it very clear and simple.One of the best I've seen by far! Keep this series going!!!

georgesamuel
Автор

I took a slightly different approach. I use list(string_to_process) so that I can swap on the list. I then use ''.join(string_as_list) to convert my list back to a string. The space complexity would be O(3n), but that is just O(n).

class Solution():

def __init__(self):
pass

def swap_vowels(self, string_to_process):

vowel_map = 'aeiou'

# pointer to the ending and beginning of our string.
start_index = 0
end_index = len(string_to_process) - 1

string_list = list(string_to_process)

while start_index < end_index:

if string_list[start_index] in vowel_map and string_list[end_index] in vowel_map:

temp_character = string_list[start_index]
string_list[start_index] = string_list[end_index]
string_list[end_index] = temp_character
start_index += 1
end_index -= 1
continue

if string_list[start_index] not in vowel_map:
start_index += 1
if string_list[end_index] not in vowel_map:
end_index -= 1

return ''.join(string_list)


string = 'ae'

scottlurowist
Автор

Great explanation, thanks. Where Is Dfs? :c u.u

pavelsjo
welcome to shbcf.ru