Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT
- 페이지 수
- 8
- 형식
- 크기
- 269 KB
- Trường
- Đại học Bách khoa Hà Nội
- 조회수
- 0
- 댓글
- 0
- Lượt tải
- 0
미리보기 생성 중...
Tài liệu giảng dạy về thuật toán Depth-First Search (DFS) và Depth-First Traversal, bao gồm các ví dụ minh họa, mã giả, cách cài đặt bằng stack và các ứng dụng trong tìm đường đi trên đồ thị.
- 문서명
- Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT
- 학교 / 강의
- Đại học Bách khoa Hà Nội · Lập trình C
- 작성자 (문서 내)
- AnhTT
- 내용
- Tài liệu này trình bày chi tiết về thuật toán duyệt đồ thị theo chiều sâu (DFS), bao gồm nguyên lý hoạt động, mã giả, ví dụ minh họa, cách triển khai bằng ngăn xếp và các ứng dụng thực tế.
- 목차
- Depth-First Search
- Depth-First Traversal
- Algorithm
- Example: Depth-First Traversal
- Using a stack
- Quiz 2
- Applications
- Path finding with DFS
- Quiz 3
- 페이지 수
- 8 페이지
- 업로더
- lienhejb
설명
Trích nội dung tài liệu
Depth-First Search 1. 2. 3. From the given vertex, visit one of its adjacent vertices and leave others; Then visit one of the adjacent vertices of the previous vertex; Continue the process, visit the graph as deep as possible until: A visited vertex is reached; An end vertex is reached. Depth-First Traversal 1. 2. 3. 4. 5. 6. 7. Depth-first traversal of a graph: Start the traversal from an arbitrary vertex; Apply depth-first search; When the search terminates, backtrack to the previous vertex of the finishing point, Repeat depth-first search on other adjacent vertices, then backtrack to one level up. Continue the process until all the vertices that are reachable from the starting vertex are visited. Repeat above processes until all vertices are visited. 0 source 0 8 9 2 4 3 source 1 7 5 6 8 9 2 4 3 1 7 5 6 1 Algorithm The pseudocode of depth-first traversal algorithm: Boolean visited[V.size]; void DepthFirst(Graph G) { Vertex u; for each vertex u in V do visited[u] = false; for each vertex u in V do if visited[u] = false then RDFS(u); } void RDFS(Vertex u){ visited[u] = true; Visit(u); for each vertex w in Adj[u] do if visited[w] = false then RDFS(w); } Example: Depth-First Traversal An adjacent list of a graph: 2 Example: Depth-First Traversal Function calls of depth-first traversal of the graph visit 0 visit 7 (first on 0’s list) visit 1 (first on 7’s list) check 7 on 1’s list check 0 on 1’s list visit 2 (second on 7’s list) check 7 on 2’s list check 0 on 2’s list check 0 on 7’s list visit 4 (fourth on 7’s list) visit 6 (first on 4’s list) check 4 on 6’s list check 0 on 6’s list Example: Depth-First Traversal visit 5 (second on 4’s list) check 0 on 5’s list check 4 on 5’s list visit 3 (third on 5’s list) check 5 on 3’s list chec
자주 묻는 질문
이 문서는 무료인가요?
네. “Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT” 문서는 무료입니다. 로그인 후 '다운로드'를 클릭하여 원본 파일을 받으세요.
이 문서는 몇 페이지로 되어 있나요?
이 문서는 8페이지입니다, Lập trình C 과정용. 다운로드하기 전에 온라인으로 미리 볼 수 있습니다.
다운로드하기 전에 미리 볼 수 있나요?
네. 이 페이지의 온라인 리더를 통해 문서를 미리 본 후 다운로드 여부를 결정할 수 있습니다.
Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT
미리보기 생성 중...
Trích nội dung tài liệu
Depth-First Search 1. 2. 3. From the given vertex, visit one of its adjacent vertices and leave others; Then visit one of the adjacent vertices of the previous vertex; Continue the process, visit the graph as deep as possible until: A visited vertex is reached; An end vertex is reached. Depth-First Traversal 1. 2. 3. 4. 5. 6. 7. Depth-first traversal of a graph: Start the traversal from an arbitrary vertex; Apply depth-first search; When the search terminates, backtrack to the previous vertex of the finishing point, Repeat depth-first search on other adjacent vertices, then backtrack to one level up. Continue the process until all the vertices that are reachable from the starting vertex are visited. Repeat above processes until all vertices are visited. 0 source 0 8 9 2 4 3 source 1 7 5 6 8 9 2 4 3 1 7 5 6 1 Algorithm The pseudocode of depth-first traversal algorithm: Boolean visited[V.size]; void DepthFirst(Graph G) { Vertex u; for each vertex u in V do visited[u] = false; for each vertex u in V do if visited[u] = false then RDFS(u); } void RDFS(Vertex u){ visited[u] = true; Visit(u); for each vertex w in Adj[u] do if visited[w] = false then RDFS(w); } Example: Depth-First Traversal An adjacent list of a graph: 2 Example: Depth-First Traversal Function calls of depth-first traversal of the graph visit 0 visit 7 (first on 0’s list) visit 1 (first on 7’s list) check 7 on 1’s list check 0 on 1’s list visit 2 (second on 7’s list) check 7 on 2’s list check 0 on 2’s list check 0 on 7’s list visit 4 (fourth on 7’s list) visit 6 (first on 4’s list) check 4 on 6’s list check 0 on 6’s list Example: Depth-First Traversal visit 5 (second on 4’s list) check 0 on 5’s list check 4 on 5’s list visit 3 (third on 5’s list) check 5 on 3’s list chec
- 문서명
- Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT
- 학교 / 강의
- Đại học Bách khoa Hà Nội · Lập trình C
- 작성자 (문서 내)
- AnhTT
- 내용
- Tài liệu này trình bày chi tiết về thuật toán duyệt đồ thị theo chiều sâu (DFS), bao gồm nguyên lý hoạt động, mã giả, ví dụ minh họa, cách triển khai bằng ngăn xếp và các ứng dụng thực tế.
- 목차
- Depth-First Search
- Depth-First Traversal
- Algorithm
- Example: Depth-First Traversal
- Using a stack
- Quiz 2
- Applications
- Path finding with DFS
- Quiz 3
- 페이지 수
- 8 페이지
- 업로더
- lienhejb
댓글 (0)
댓글이 없습니다. 첫 댓글을 남겨보세요!
K5 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K2 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K3 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K4 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K1 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)

댓글 (0)
댓글이 없습니다. 첫 댓글을 남겨보세요!