Professional Documents
Culture Documents
Chapter 3 Algorithms
Chapter 3 Algorithms
Algorithms
Group 3
Table of Contents
01 Complexity of an
algorithm
=> This is a worst case analysis. Because the largest number of operations
needed to solve the given problem using this algorithm on input of specified
size.
DEFINITION
Thuật toán phải kiểm tra từng phần tử một từ 3 đến 9, tổng
cộng 5 lần so sánh.
Conclusion
While sorting bubbles, the worst case occurs when the list to be
sorted has been sorted in exactly the opposite order to the
desired order. This means having to change every pair of
elements in succession until there are no more elements that
need to be changed. This requires a maximum number of
iterations, making the algorithm inefficient with large lists.
Example
If the original list is [3, 2, 4, 1, 5], then we need to sort it into [1, 2, 3, 4, 5].
Answer
(5-1).5 20
= = 10
2 2
Conclusion