Tree Traversals, Tries, KD Trees (Discussion 9) (Các phép duyệt cây) - Christine Zhou
Generating preview...
Tài liệu thảo luận về các phép duyệt cây, Trie, và cây K-D, bao gồm lý thuyết và bài tập thực hành.
Description
Discussion 9: Tree Traversals, Tries, K-D Trees Christine Zhou Agenda K-D Tree review (with demos from lecture) K-D Tree problems Tree Traversal review Tree Traversal problems Trie review Trie problems Announcements Project 2B is due on Saturday, March 23 at 11:59pm. Remember that these are real deadlines (not "checkpoints") Midterm 2 is on April 5th from 8-10pm. Here are some events to keep on your radar! Check out Hug’s updated kd-tree nearest video @3426 Course Staff Guerrilla Section - 3/31 12-2PM Soda Labs HKN Review Session - 3/31 3-6PM HP Auditorium CSM Review Session - 4/1 6-9PM HP Auditorium Discussion survey: tinyurl.com/cz-disc9-sp19 Tree Traversals Level-Order/Breadth First Search (BFS): ○ Visit top to bottom, left to right, just like how you read! Depth-order/Depth First Search (DFS): ○ Traverse “deeper” nodes before shallow ones Types of DFS: Preorder Pre-Order: “Visit” a node, then traverse its children preOrder(BSTNode x) { if (x == null) return; print(x.key) preOrder(x.left) preOrder(x.right) } Pre-Order: DBACFEG Hack: draw “pegs” on the left side of each node and take a walk around the edges of the tree. The Preorder is the order in which you hit the pegs Types of DFS: Inorder In-Order: Traverse left child, “visit” node, then traverse right child inOrder(BSTNode x) { if (x == null) return; inOrder(x.left) print(x.key) inOrder(x.right)} In-Order: ABCDEFG Hack: draw “pegs” on the bottom of each node and take a walk around the edges of the tree. The Inorder is the order in which you hit the pegs Types of DFS: Postorder Post-Order: Traverse children, then “visit” node. postOrder(BSTNode x) { if (x == null) return; postOrder(x.left) postOrder(x.right) print(x.key) } Post-Order: ACBEGFD Hack: draw “pegs” on the right side of each node and take a walk around the edges of the tree. The postorder is the order in which you hit the pegs Problem 1.1
AI summary
- Document name
- Tree Traversals, Tries, KD Trees (Discussion 9) (Các phép duyệt cây) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu này cung cấp kiến thức ôn tập và bài tập thực hành về K-D Tree, các phương pháp duyệt cây (BFS, DFS: Preorder, Inorder, Postorder) và cấu trúc dữ liệu Trie. Các khái niệm được giải thích rõ ràng kèm ví dụ và mẹo ghi nhớ, cùng với lời giải cho các bài tập.
- Table of contents
- Agenda
- Announcements
- Tree Traversals
- Types of DFS: Preorder
- Types of DFS: Inorder
- Types of DFS: Postorder
- Problem 1.1
- Solution
- Tries
- Runtime of Tries
- Problem 2.1
- Solutions
- Pages
- 65 pages
- Uploaded by
- Uni24h
Frequently asked questions
Is this document free?
Yes. “Tree Traversals, Tries, KD Trees (Discussion 9) (Các phép duyệt cây) - Christine Zhou” is free — just sign in and click Download to get the original file.
How many pages is this document?
The document has 65 pages, for the course Lập trình Java. You can preview it online before downloading.
Can I preview before downloading?
Yes. You can preview this document right on this page with the online reader, then decide whether to download.
Tree Traversals, Tries, KD Trees (Discussion 9) (Các phép duyệt cây) - Christine Zhou
Generating preview...
Discussion 9: Tree Traversals, Tries, K-D Trees Christine Zhou Agenda K-D Tree review (with demos from lecture) K-D Tree problems Tree Traversal review Tree Traversal problems Trie review Trie problems Announcements Project 2B is due on Saturday, March 23 at 11:59pm. Remember that these are real deadlines (not "checkpoints") Midterm 2 is on April 5th from 8-10pm. Here are some events to keep on your radar! Check out Hug’s updated kd-tree nearest video @3426 Course Staff Guerrilla Section - 3/31 12-2PM Soda Labs HKN Review Session - 3/31 3-6PM HP Auditorium CSM Review Session - 4/1 6-9PM HP Auditorium Discussion survey: tinyurl.com/cz-disc9-sp19 Tree Traversals Level-Order/Breadth First Search (BFS): ○ Visit top to bottom, left to right, just like how you read! Depth-order/Depth First Search (DFS): ○ Traverse “deeper” nodes before shallow ones Types of DFS: Preorder Pre-Order: “Visit” a node, then traverse its children preOrder(BSTNode x) { if (x == null) return; print(x.key) preOrder(x.left) preOrder(x.right) } Pre-Order: DBACFEG Hack: draw “pegs” on the left side of each node and take a walk around the edges of the tree. The Preorder is the order in which you hit the pegs Types of DFS: Inorder In-Order: Traverse left child, “visit” node, then traverse right child inOrder(BSTNode x) { if (x == null) return; inOrder(x.left) print(x.key) inOrder(x.right)} In-Order: ABCDEFG Hack: draw “pegs” on the bottom of each node and take a walk around the edges of the tree. The Inorder is the order in which you hit the pegs Types of DFS: Postorder Post-Order: Traverse children, then “visit” node. postOrder(BSTNode x) { if (x == null) return; postOrder(x.left) postOrder(x.right) print(x.key) } Post-Order: ACBEGFD Hack: draw “pegs” on the right side of each node and take a walk around the edges of the tree. The postorder is the order in which you hit the pegs Problem 1.1
Read full document
- Document name
- Tree Traversals, Tries, KD Trees (Discussion 9) (Các phép duyệt cây) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu này cung cấp kiến thức ôn tập và bài tập thực hành về K-D Tree, các phương pháp duyệt cây (BFS, DFS: Preorder, Inorder, Postorder) và cấu trúc dữ liệu Trie. Các khái niệm được giải thích rõ ràng kèm ví dụ và mẹo ghi nhớ, cùng với lời giải cho các bài tập.
- Table of contents
- Agenda
- Announcements
- Tree Traversals
- Types of DFS: Preorder
- Types of DFS: Inorder
- Types of DFS: Postorder
- Problem 1.1
- Solution
- Tries
- Runtime of Tries
- Problem 2.1
- Solutions
- Pages
- 65 pages
- Uploaded by
- Uni24h
Comments (0)
No comments yet. Be the first!
Misc.onclusion (Discussion 14-END) (Ôn tập cấu trúc dữ liệu) - Christine Zhou
Final Review Solutions (Cấu trúc dữ liệu heap, hàng đợi ưu tiên và duyệt đồ thị) - Ching and Christines
Giáo trình Lập trình Java
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
Chương 7.Cơ học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 6.Quang học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 5.Thuyết tương đối - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 4. Tán xạ ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 3.Phân cực ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Comments (0)
No comments yet. Be the first!