Search the depths Let the graph G = (V, E) and a fixed initial vertex v. At DFS changing strategy revision vertices. Motion carried from one vertex to another adjacent to it, gradually moving away from the starting vertex until we reach the impasse. Top undirected graph is a dead end, since I visited all adjacent vertices. In a directed graph it can be top, from which there comes no edge (off Powers 0). Returns the deadlock is carried king size along the traversed path until you meet the top, in which there are not visited by a neighbor, and then motion is carried out in a new direction. The process is completed when the return to the top and start all adjacent vertices will be visited. For the uniqueness of the algorithm select one of several adjacent peaks is carried out lexicographical principle king size - top elected with a smaller number or a lower value of a trait. Problem. Write a program that implements the algorithm DFS. Connected undirected graph represented by the adjacency matrix. Given summit, which begins bypass graph. When you visit another vertex program prints its number. To solve the applicable king size array lb, which contains check boxes for each vertex, which means sooner or vidviduvalas corresponding king size peak. Implements the algorithm using a recursive procedure. If you found another vertex adjacent to it the node that has not been visited, print the number of the next summit, we see it as a recursive call to a related procedure. If adjacent unvisited vertices are found, then come back with recursion. Problem. Every room in the school of computer science has its own local network. School computers have names that correspond to the numbers from 1 to N. To connect all computers to the Internet director decided to do a combined network of local schools. To do this, each cabinet informatics should outlast the cable to the hub of the school. How many free ports should king size be a hub for connecting each office? The input file is a number of computers at school and N adjacency matrix, which is fixed between which communication channels are laid computers in local network classes. The output file number display cabinets science in school.
Center nationwide competition Hmelnitskie Ukrainian Olympiad in Informatics olympyadы Molodёzhnoe nauchnoe Society Dyskretnaya Mathematics E-Olimp system of training and the competition for sports programming
No comments:
Post a Comment