Data Structures (Discussion 6) (Cấu trúc dữ liệu Disjoint Sets và Asymptotics) - Christine Zhou
Generating preview...
Tài liệu thảo luận số 6 môn CS61B (Data Structures) về cấu trúc dữ liệu Disjoint Sets và Asymptotics, bao gồm các phép toán quick find, quick union, weighted quick union và path compression.
Description
CS61B Discussion 6 Disjoint Sets and Asymptotics Administrivia Fill out the weekly surveys! ○ Pacing points and feedback you have for us :); check Piazza! Midterm 1 solutions and grades are out! CSM sections are available, http://scheduler.csmentors.org/! Post-midterm advising appointments ○ Sign-up on Piazza or let me know if you want to talk in the discussion survey today. Optional online textbook! ○ You can find readings that correspond to the lecture videos under the ‘Readings’ column of the website Discussion survey (please fill this out!): tinyurl.com/cz-disc6-sp19 Disjoint Sets Also sometimes called “Union Find” keeps track of whether or not elements are connected ○ empires that are constantly conquering one another ○ each empire is identified by a ruling element. Three basic functions: Also sometimes called union(a, b) ○ connect(a, b) ■ brings b into a’s empire (a conquers b) ○ isConnected(a, b) ■ returns whether or not a and b are in the same empire. ○ find(a) ■ Returns the “ruler” of empire a. Implementations of Disjoint Sets Disjoint sets can be implemented in multiple ways, each with its own benefits and drawbacks. ○ Quick Find → quick to find if two are connected ○ Quick Union → quick to connect ○ Weighted Quick Union → quick union, but with some optimization Quick Find Use an array to store which set each element is in. Called quick find because it is very fast to find if two elements are in the same set (isConnected(a,b)), since you just need to check if id[a] = id[b]. 0 4 1 2 3 5 6 { 0, 1, 2, 4 }, {3, 5}, {6} 0 int[] id 0 1 2 3 4 5 6 0 0 3 0 3 6 Analogy: Each set is an “empire” and is identified by its ruler. 0, 3, 6 are the individual rulers and all the other elements belong to their empires. Quick Union Use an array to store the parent of each node -1 indicates that an item is a root. int[] parent 1 0 0 1 1 2 1 0 3 3 4 5 1 6 0 3 1 4 2 6 5 Weighted Quick Union Quick Union,
AI summary
- Document name
- Data Structures (Discussion 6) (Cấu trúc dữ liệu Disjoint Sets và Asymptotics) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu giới thiệu cấu trúc dữ liệu Disjoint Sets với các phương pháp triển khai khác nhau (Quick Find, Quick Union, Weighted Quick Union) và phân tích hiệu năng. Nó cũng đưa ra các bài tập để củng cố kiến thức về Disjoint Sets.
- Table of contents
- Administrivia
- Disjoint Sets
- Implementations of Disjoint Sets
- Quick Find
- Quick Union
- Weighted Quick Union
- Weighted Quick Union with Path Compression
- Disjoint Set Runtimes
- Problem 1.1
- Problem 1.1 Solutions
- Problem 1.2
- Pages
- 83 pages
- Uploaded by
- Uni24h
Frequently asked questions
Is this document free?
Yes. “Data Structures (Discussion 6) (Cấu trúc dữ liệu Disjoint Sets và Asymptotics) - Christine Zhou” is free — just sign in and click Download to get the original file.
How many pages is this document?
The document has 83 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.
Data Structures (Discussion 6) (Cấu trúc dữ liệu Disjoint Sets và Asymptotics) - Christine Zhou
Generating preview...
CS61B Discussion 6 Disjoint Sets and Asymptotics Administrivia Fill out the weekly surveys! ○ Pacing points and feedback you have for us :); check Piazza! Midterm 1 solutions and grades are out! CSM sections are available, http://scheduler.csmentors.org/! Post-midterm advising appointments ○ Sign-up on Piazza or let me know if you want to talk in the discussion survey today. Optional online textbook! ○ You can find readings that correspond to the lecture videos under the ‘Readings’ column of the website Discussion survey (please fill this out!): tinyurl.com/cz-disc6-sp19 Disjoint Sets Also sometimes called “Union Find” keeps track of whether or not elements are connected ○ empires that are constantly conquering one another ○ each empire is identified by a ruling element. Three basic functions: Also sometimes called union(a, b) ○ connect(a, b) ■ brings b into a’s empire (a conquers b) ○ isConnected(a, b) ■ returns whether or not a and b are in the same empire. ○ find(a) ■ Returns the “ruler” of empire a. Implementations of Disjoint Sets Disjoint sets can be implemented in multiple ways, each with its own benefits and drawbacks. ○ Quick Find → quick to find if two are connected ○ Quick Union → quick to connect ○ Weighted Quick Union → quick union, but with some optimization Quick Find Use an array to store which set each element is in. Called quick find because it is very fast to find if two elements are in the same set (isConnected(a,b)), since you just need to check if id[a] = id[b]. 0 4 1 2 3 5 6 { 0, 1, 2, 4 }, {3, 5}, {6} 0 int[] id 0 1 2 3 4 5 6 0 0 3 0 3 6 Analogy: Each set is an “empire” and is identified by its ruler. 0, 3, 6 are the individual rulers and all the other elements belong to their empires. Quick Union Use an array to store the parent of each node -1 indicates that an item is a root. int[] parent 1 0 0 1 1 2 1 0 3 3 4 5 1 6 0 3 1 4 2 6 5 Weighted Quick Union Quick Union,
Read full document
- Document name
- Data Structures (Discussion 6) (Cấu trúc dữ liệu Disjoint Sets và Asymptotics) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu giới thiệu cấu trúc dữ liệu Disjoint Sets với các phương pháp triển khai khác nhau (Quick Find, Quick Union, Weighted Quick Union) và phân tích hiệu năng. Nó cũng đưa ra các bài tập để củng cố kiến thức về Disjoint Sets.
- Table of contents
- Administrivia
- Disjoint Sets
- Implementations of Disjoint Sets
- Quick Find
- Quick Union
- Weighted Quick Union
- Weighted Quick Union with Path Compression
- Disjoint Set Runtimes
- Problem 1.1
- Problem 1.1 Solutions
- Problem 1.2
- Pages
- 83 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!