Data Structures and Algorithms in Java 4th phần 10

Hình 9,8: Ví dụ về một tìm kiếm nhị phân để thực hiện hoạt động tìm kiếm (22), trong một dictio BREW để giúp với các phím số nguyên, thực hiện với một danh sách mảng đã ra lệnh. Để đơn giản, chúng tôi cho thấy các phím được lưu trữ trong từ điển nhưng không phải là toàn bộ mục. | As with undirected graphs we can explore a digraph in a systematic way with methods akin to the depth-first search DFS and breadth-first search BFS algorithms defined previously for undirected graphs Sections and . Such explorations can be used for example to answer reachability questions. The directed depth-first search and breadth-first search methods we develop in this section for performing such explorations are very similar to their undirected counterparts. In fact the only real difference is that the directed depth-first search and breadth-first search methods only traverse edges according to their respective directions. The directed version of DFS starting at a vertex v can be described by the recursive algorithm in Code Fragment . See Figure . Code Fragment The Directed DFS algorithm. Algorithm DirectédDFS ỵ i Mark vertex vas visited. for each outgoing edge v. H of V do if vertex ir has not been visited then Recursively call Directed DFS mộ. Figure An example of a DFS in a digraph a intermediate step where for the first time an already visited vertex DFW is reached b the completed DFS. The tree edges are shown with solid blue lines the back edges are shown with dashed blue lines and the forward and cross edges are shown with dashed black lines. The order in which the vertices are visited is indicated by a label next to each vertex. The edge ORD DFW is a back edge but DFW ORD is a forward edge. Edge BOS SFO is a forward edge and SFO LAX is a cross edge. 830 A DFS on a digraph G partitions the edges of G reachable from the starting vertex into tree edges or discovery edges which lead us to discover a new vertex and nontree edges which take us to a previously visited vertex. The tree edges form a tree rooted at the starting vertex called the depth-first search tree and there are three kinds of nontree edges back edges which connect a vertex to an ancestor in the DFS tree forward edges which connect a vertex to a descendent in

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
29    174    4    25-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.