PDF Google Drive Downloader v1.1


Report a problem

Content text 12- thuật toán sắp xếp.pdf


Become A Better Developer 28TECH 28tech.com.vn 2 Thuật toán sắp xếp: Sắp xếp là một thuật toán quan trọng, được sử dụng cực kì nhiều trong các ứng dụng thực tế. Các bạn có thể không biết các thuật toán như quy hoạch động, chia và trị nhưng bắt buộc phải nắm được sắp xếp và tìm kiếm.
Become A Better Developer 28TECH 28tech.com.vn 3 1.Thuật toán sắp xếp chọn (Selection sort): void selectionSort(int a[], int n){ for(int i = 0; i < n; i++){ int min_pos = i; for (int j = i + 1; j < n; j++){ if (a[j] < a[min_pos]){ min_pos = j; } } swap(a[min_pos], a[i]); } } Độ phức tạp: O(N^2)
Become A Better Developer 28TECH 28tech.com.vn 4 2.Thuật toán sắp xếp nổi bọt (Bubble sort): void bubbleSort(int a[], int n){ for(int i = 0; i < n; i++){ for(int j = 0; j < n - i - 1; j++){ if (a[j] > a[j + 1]){ swap(a[j], a[j + 1]); } } } } Độ phức tạp: O(N^2)

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.