00:01
4 .1 given a list of cities and distance between each pair of cities, find the cheapest way to build a rail system such that every single city is connected in some other way to everyone.
00:19
So one approach to solve this problem by using minimum spanning tree, that is mst algorithm such as prim's algorithm or kruskal's algorithm.
00:39
These two algorithms find the minimum cost tree that connects all the cities together.
00:44
In this case, the cities represents the node of the tree and the distance between each pair of the cities represents the edge weights.
00:51
So by finding the mst, we can determine the cheapest way to build the rail system that connects all the cities.
01:00
For 4 .2 finding the correct answer to a sudoku puzzle.
01:05
To solve a sudoku puzzle, we can use a backtracking algorithm.
01:25
So this algorithm starts by filling in an empty cell with a number from 1 to 9 and checks if it violates any of the sudoku rules.
01:35
If the number is valid, it moves on to the next empty cell and repeats the process.
01:39
If it is invalid, it retries the next number.
01:42
If all numbers have been tried and none of them valid, it backtracks to the previous cell and tries with the different numbers.
01:48
This process continues until the puzzle is filled.
01:52
For 4 .3 listing basketball teams by most number of wins, tie -breaking by the number of games played and alphabetical order of the names...