Programming Assignment 1 Bkc1975
Programming Assignment 1 Bkc1975
Programming Assignment 1 Bkc1975
PROGRAMING?
ALGORITHM STUDY
COMPLEXITY?
CONCEPTS FOR CREATING ARTS
Determine the complexity of some simple algorithms.
• A problem has many algorithms, so it is necessary to choose the fastest solution.
1. Data size: the larger the data, the slower the processing time is. If n is the data size, the execution time of an
algorithm can be represented as a function of n: T (n).
2. Computer hardware
=> So can not rely on the algorithm execution time to determine T (n), we represent the algorithm execution time
only depends on the data size n
DEFINITIONS OF
INTEGRITY EXPERIENCE
• The complexity algorithm is a constant, the execution time does not depend on the data size n, we denote the
complexity as O(1).
• If the algorithm has execution time of P(n), where P(n) is a k-degree polynomial, the computational complexity
of the algorithm can be written as O().
• Sorted array binary search algorithm destroys half of the data after each iteration of complexity O (lo (n)). If the
algorithm can destroy 90% of the data after each iteration then there is O complexity (lo(n)).
• If an algorithm has an execution time of lof (n). We see that lof (n) = lob. lof (n), meaning O (lof (n)) = O (lof
(n)). Therefore, we only record the complexity of the algorithm as O (log f (n)) and not record the logarithmic
base.
BUBBLE SORT
Efficiency of bubble sort O(n):
• The best : n
• Worst :
ALGORITHM?
LINEAR SEARCH
ALGORITHM
This is the simplest of all the search algorithms.
In this type of search, a consecutive search is
performed on all the elements. Each element is
checked and if any match is found then that
particular element is returned; If a match is not
found, the search continues until the search is
exhausted.
ALGORITHM?
THE BINARY SEARCH
ALGORITHM
Binary search - binary search, also known as
half-range search, logarithmic search, or
binary search, is a search algorithm that
determines the position of the look up value in
an ordered array. boss. An algorithm that
compares the desired value with the element in
the middle of the array
Time complexity: O(log [n]) on that basis of
log = 2
Spatial complexity: O(1) performs iteration
while O (log [n]) does recursion because with
each recursive call, a new graph is created.
THIS IS A RECURSIVE
IMPLEMENTATION OF
BINARY SEARCH IN
PYTHON
REFERENCE
• https://kcntt.duytan.edu.vn/Home/ArticleDetail/vn/168/2005/do-phuc-tap-cua-giai-thuat-algorithm-complexity
• https://codelearn.io/sharing/cai-thien-ky-nang-thuat-toan-the-nao
• https://codelearn.io/sharing/5-thuat-toan-tim-kiem-moi-ltv-nen-biet
• https://vi.wikipedia.org/wiki/T%C3%ACm_ki%E1%BA%BFm_nh%E1%BB%8B_ph%C3%A2n
• https://helpex.vn/article/thuat-toan-cua-tuan-tim-kiem-nhi-phan-5c548fb3507419248c9ac2c0
CONTACT US
THANH YOU