More Sorting (Discussion 13) (Thuật toán sắp xếp nâng cao) - Christine Zhou
Đang tạo bản xem trước...
Tài liệu thảo luận về các thuật toán sắp xếp nâng cao: Quicksort, tính ổn định, Counting Sort/Radix Sort.
Mô tả
Discussion 13: More Sorting Christine Zhou Agenda Announcements (Probably only 2 of these) Quicksort Review Problem 1 Stability Review Problem 2 Radix Sorts Problem 3 Announcements Practice Mock Final: Tuesday 5/7 in Dwinelle 155, from 7-10PM Project 3 Phase 1 is due Friday at 11:59pm! Office hours Remember the policies Only 1 more discussion section!! Discussion survey: tinyurl.com/cz-disc13-sp19 Quicksort Algorithm: Pick a pivot, partition elements based on the pivot, repeat on partitions as long as they include more than one element, then combine partitions How to pick a pivot? How to partition? Always pick the leftmost/rightmost element Randomly pick an element Three way merge: split into the less than, equal, and greater than partition (auxiliary arrays) Hoare: split into less than or equal to and greater than partition (in place) Runtime: (which part of the algorithm most heavily influences the runtime?) Pivot choice! 1 Quicksort Sort the following unordered list using stable quicksort. Assume that the pivot you use is always the first element and that we use the 3-way merge partitioning process described in lecture and lab last week. Show the steps taken at each partitioning step. 18, 7, 22, 34, 99, 18, 11, 4 1 Quicksort 18-, 7, 22, 34, 99, 18, 11, 4 (18 is the pivot) 7-, 11, 4 | 18, 18 | 22, 34, 99 (7 is the pivot) 4, 7, 11, 18, 18 | -22-, 34, 99 (22 is the pivot) 4, 7, 11, 18, 18, 22 | -34-, 99 (34 is the pivot) 4, 7, 11, 18, 18, 22, 34, 99 1 Quicksort What is the best and worst case running time of Quicksort with Hoare Partitioning on N elements? Give an example of a list of 5 numbers that would result in best and worst case running time. Best: Theta(N log N) Example: 3 1 2 5 4 Worst: Theta(N^2) Example: 1 3 3 4 5 (if the first or last element is picked as the pivot) 1 Quicksort What are two techniques that can be used to reduce the probability of Quicksort taking the worst case running time? 1. Randomly ch
Tóm tắt AI
- Tên tài liệu
- More Sorting (Discussion 13) (Thuật toán sắp xếp nâng cao) - Christine Zhou
- Trường / Môn
- University of California, Berkeley · Lập trình Java
- Tác giả (trong tài liệu)
- Christine Zhou
- Nội dung
- Tài liệu thảo luận về Quicksort, tính ổn định của thuật toán sắp xếp, và Radix Sort. Bao gồm các ví dụ minh họa, phân tích hiệu năng và các yếu tố đánh đổi khi thiết kế thuật toán.
- Mục lục
- Agenda
- Announcements
- Quicksort
- 1 Quicksort
- Stability
- 2.1
- 2.2
- 2.3
- 2.4
- Counting Sorts
- Counting Sorts Demo
- Số trang
- 79 trang
- Người đăng
- Uni24h
Câu hỏi thường gặp
Tài liệu này có miễn phí không?
Có. “More Sorting (Discussion 13) (Thuật toán sắp xếp nâng cao) - Christine Zhou” miễn phí — bạn chỉ cần đăng nhập rồi bấm Tải xuống để lấy file gốc.
Tài liệu dài bao nhiêu trang?
Tài liệu gồm 79 trang, thuộc môn Lập trình Java. Bạn có thể xem trước online trước khi tải.
Tôi có thể xem trước trước khi tải không?
Có. Bạn xem trước tài liệu ngay trên trang này bằng trình đọc online, rồi quyết định tải về.
More Sorting (Discussion 13) (Thuật toán sắp xếp nâng cao) - Christine Zhou
Đang tạo bản xem trước...
Discussion 13: More Sorting Christine Zhou Agenda Announcements (Probably only 2 of these) Quicksort Review Problem 1 Stability Review Problem 2 Radix Sorts Problem 3 Announcements Practice Mock Final: Tuesday 5/7 in Dwinelle 155, from 7-10PM Project 3 Phase 1 is due Friday at 11:59pm! Office hours Remember the policies Only 1 more discussion section!! Discussion survey: tinyurl.com/cz-disc13-sp19 Quicksort Algorithm: Pick a pivot, partition elements based on the pivot, repeat on partitions as long as they include more than one element, then combine partitions How to pick a pivot? How to partition? Always pick the leftmost/rightmost element Randomly pick an element Three way merge: split into the less than, equal, and greater than partition (auxiliary arrays) Hoare: split into less than or equal to and greater than partition (in place) Runtime: (which part of the algorithm most heavily influences the runtime?) Pivot choice! 1 Quicksort Sort the following unordered list using stable quicksort. Assume that the pivot you use is always the first element and that we use the 3-way merge partitioning process described in lecture and lab last week. Show the steps taken at each partitioning step. 18, 7, 22, 34, 99, 18, 11, 4 1 Quicksort 18-, 7, 22, 34, 99, 18, 11, 4 (18 is the pivot) 7-, 11, 4 | 18, 18 | 22, 34, 99 (7 is the pivot) 4, 7, 11, 18, 18 | -22-, 34, 99 (22 is the pivot) 4, 7, 11, 18, 18, 22 | -34-, 99 (34 is the pivot) 4, 7, 11, 18, 18, 22, 34, 99 1 Quicksort What is the best and worst case running time of Quicksort with Hoare Partitioning on N elements? Give an example of a list of 5 numbers that would result in best and worst case running time. Best: Theta(N log N) Example: 3 1 2 5 4 Worst: Theta(N^2) Example: 1 3 3 4 5 (if the first or last element is picked as the pivot) 1 Quicksort What are two techniques that can be used to reduce the probability of Quicksort taking the worst case running time? 1. Randomly ch
Đọc toàn bộ tài liệu
- Tên tài liệu
- More Sorting (Discussion 13) (Thuật toán sắp xếp nâng cao) - Christine Zhou
- Trường / Môn
- University of California, Berkeley · Lập trình Java
- Tác giả (trong tài liệu)
- Christine Zhou
- Nội dung
- Tài liệu thảo luận về Quicksort, tính ổn định của thuật toán sắp xếp, và Radix Sort. Bao gồm các ví dụ minh họa, phân tích hiệu năng và các yếu tố đánh đổi khi thiết kế thuật toán.
- Mục lục
- Agenda
- Announcements
- Quicksort
- 1 Quicksort
- Stability
- 2.1
- 2.2
- 2.3
- 2.4
- Counting Sorts
- Counting Sorts Demo
- Số trang
- 79 trang
- Người đăng
- Uni24h
Bình luận (0)
Chưa có bình luận nào. Hãy là người đầu tiên!
Java DataBase Connectivity - Kết nối kho dữ liệu Java
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
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
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
Bình luận (0)
Chưa có bình luận nào. Hãy là người đầu tiên!