# Лекция №3. Анализ алгоритмов. Предмет "Структуры и алгоритмы обработки данных"

• View
1.769

8

Embed Size (px)

Transcript

• 1. . .. : , www.grebenshikov.ru

2. - - . 1 3. , ? 2 4. ( ) 3 5. ? 4 6. - , . 5 7. : C: < a1, a2, ..., an >: < a1, a2, ..., an >, a1 a2 , ..., an6 8. Insertion-Sort(A, n) 1 for j 2 to n 2 do key A[j] 3 Insert A[j] into the sorted sequence A[1 . . j 1]. 4ij1 5while i > 0 and A[i] > key 6 do A[i + 1] A[i] 7 ii1 8A[i + 1] key 7 9. 8 10. 9 (1)5 7 3 219(5)7 3 215 9(7)3 215 7 9(3)213 5 7 9(2)12 3 5 7 99 11. (, ) () 10 12. : T (n) - - n. : T (n) - - n. ( ???) - . 11 13. InsertionSort ? ( ) ( ) 12 14. : - T (n) n 13 15. -. .4n3 + 12n2 10n + 1234 = (n3)14 16. (n3) (n2)15 17. : : - .n T (n) = (n) = (n2) ( ) 2 ? , n , n 16 18. A[1..n] 1. n = 1, . 2. A[1.. n/2 ] A[ n/2 + 1..n]. 3. . 17 19. ?T (n) = (n), n - 18 20. T (n) - A[1..n] 1. (1) - n = 1, . 2. 2T (n/2) - A[1.. n/2 ] A[ n/2 +1..n]. 3. (n) - . 19 21. (1)n=1; T (n) = 2T (n/2) + (n) n>1. : T (n) = 2T (n/2) + cn, c const, c > 020 22. : T (n) = 2T (n/2) + cn, c const, c > 021 23. 22 24. 23 25. T (n) = cnlog2(n)+(n) = (n)log2(n)+(n) = (nlog2(n)+ n) = (n log2(n))24 26. - (n2) - (n log2(n)) 25 27. ., ., . . - . : , 2000..27-36. ., ., ., . -: , 2- . - . : - , 2007. .11-15. 26