Programming Assignment 1 Bkc1975

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

PROGRAMMING

ASSIGNMENT 1 – ALGORITHM DESIGN


1.What an algorithm is in programing
2.Algorithm studyprograming
OUTLINE 3.Algorithm complexity
4.Concepts for creating arts
5.Definitions os integrity experience
6.Properties os creativity solutions
7.Bubble sort
8.Linear search algorithm
9.Example of a linear search
10.
The Binary Search algorithm
11.
Implement binary search in python
12.
Reference
WHAT AN
ALGORITHM IS IN “…

PROGRAMING?
ALGORITHM STUDY

You can think of a programming algorithm as


a recipe that describes the exact steps needed
for the computer to solve a problem or reach a
goal

 A programming algorithm describes how to do


something, and your computer will do it exactly
that way every time.
ALGORITHM “…

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.

• The execution time of the algorithm depends on:

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

3. Language, language translation program

=> 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

Complexity is indicated by a large "O"

• The complexity of the function f (n) is O (g


(n)), if there exists a positive constant c and k
such that f (n) ≤ c.g (n) for all n ≥ k

• The asymptote c.g (n) of the curve is the line


for which the distance to a given curve
approaches 0

• Find asymptote with a data set called


asymptotic analysis
PROPERTIES OF CREATIVITY SOLUTIONS

•  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 :

Advantages : the most concise code

Defects : lowest performance


LINEAR SEARCH “…

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.

Time complexity: O (n)

Spatial complexity: O (1)


HERE IS AN EXAMPLE OF
A LINEAR SEARCH
IMPLEMENTATION IN
PYTHON
THE BINARY
SEARCH “…

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

VK FACEBOOK EMAIL PHONE


Vu Khuong KHƯƠNG THẾ VŨ KHUONGTHEVUK47A2@GM 08 2527 2160
AIL.COM

You might also like