0% found this document useful (0 votes)
9 views33 pages

IP07 Algorithm Part1

The document is an introduction to programming with a focus on algorithms using Python, presented by Dr. Nguyen Dinh Long. It covers key concepts such as data structures, types of algorithms, and the importance of algorithms in programming. The content includes practical exercises and examples to illustrate algorithm design and implementation in Python.

Uploaded by

24166108
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views33 pages

IP07 Algorithm Part1

The document is an introduction to programming with a focus on algorithms using Python, presented by Dr. Nguyen Dinh Long. It covers key concepts such as data structures, types of algorithms, and the importance of algorithms in programming. The content includes practical exercises and examples to illustrate algorithm design and implementation in Python.

Uploaded by

24166108
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Trường Đại Học Nông Lâm TP.

Hồ Chí Minh
Ngành Hệ Thống Thông Tin

NHẬP MÔN LẬP TRÌNH


(Introduction to Programming)
Chapter 7 – Algorithm with Python
(Lesson 1 – Thinking in Algorithm …)

Presenter: Dr. Nguyen Dinh Long 1


Email: dinhlonghcmut@[Link]
Phone: +84 947 229 599
Google-site: [Link]
Jan. 2026
Dr. Long D. Nguyen
Programming

In 2016, President Barack Obama awarded Hamilton the Medal


of Freedom, noting that “her example speaks of the American
spirit of discovery.” Official White House photo by Lawrence
Jackson 2
Outline
Overview of Computer, Computing and Programming

Basic Concepts and Data Forms

Variable and Function in Programming

Sequence/Array and Its Structure

Commands and Control Structure

Pointer and Application

Algorithm and Application Programming


3
Computer programs
❑ General structure:

5
Content of Chapter 7
1. What is algorithm? Thinking in algorithms

2. Data structure and Algorithms

3. Applications

6
Structure of Computer programs
❑ Python Programming Analysis:

▪ Objects

▪ Types: boolean, integer, float, string, complex

▪ Variables: global variables, local variables

▪ Methods, Calculation, Computations

▪ Classes, functions

▪ Sequences: list, tuples, set, dictionary

▪ Arrays: 1D array (vector), 2D array (matrix), n-D array ...

7
Structure of Computer programs
❑ Computer programming:

▪ Modeling

▪ Data Reading-Writing-Updating-Deleting

▪ Flow charts, diagram, graph/figure ...

8
Python Command/Control/Statement
❑ For ... loop, While ... Loop, If/else ... statement

9
Python Algorithms
❑ What is an algorithm?

10
Python Algorithms

Python Programming

Algorithms

11
Python Algorithms
❑ What is an algorithm?

▪ An algorithm is a procedure to accomplish a specific task or a group of tasks.

▪ An algorithm is the idea behind any reasonable computer program.

▪ A set of finite rules or instructions to be followed in calculations or other problem-solving operations.

▪ A procedure for solving a mathematical problem in a finite number of steps that frequently involves
recursive operations.

12
Python Algorithms
❑ What is an algorithm?

▪ An algorithm is a procedure to accomplish a specific task or a group of tasks.

▪ An algorithm is the idea behind any reasonable computer program.

▪ A set of finite rules or instructions to be followed in calculations or other problem-solving operations.

▪ A procedure for solving a mathematical problem in a finite number of steps that frequently involves
recursive operations.

13
Python Algorithms
❑ Thinking in Algorithms:

▪ Data structures have been tightly tied to algorithms since the dawn of computing.

▪ A number of general approaches used by algorithms to solve problems.

▪ What do you need to do when choosing an algorithm?

14
Python Algorithms
❑ Thinking in Algorithms:

▪ The first step in designing an algorithm is to understand the problem you want to solve.

▪ Let’s start with a sample problem from the field of computational geometry.

15
Python Algorithms
❑ Thinking in Algorithms:

▪ Let’s start with a sample problem from the field of computational geometry.

16
Python Algorithms
❑ Why Data Structures and Algorithms?

▪ This is for those who have just started learning algorithms and wondered how impactful it will be to boost their
career/programming skills. It is also for those who wonder why big companies like Google, Facebook, and Amazon
hire programmers who are exceptionally good at optimizing Algorithms.

▪ Programming is all about data structures and algorithms. Data structures are used to hold data while algorithms are
used to solve the problem using that data.
▪ Data structures and algorithms (DSA) goes through solutions to standard problems in detail and gives you an insight
into how efficient it is to use each one of them. It also teaches you the science of evaluating the efficiency of an
algorithm. This enables you to choose the best of various choices.

17
Python Algorithms
❑ Why Data Structures and Algorithms?

18
Python Algorithms
❑ Data Structure and Types:

▪ Data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so
that it can be accessed and updated efficiently.

Types of Data Structure. Basically, data structures are divided into two categories:
▪ Linear data structure

▪ Non-linear data structure

19
Python Algorithms
❑ Data Structure and Types:

▪ Data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so
that it can be accessed and updated efficiently.

20
Python Algorithms
❑ Types of Algorithms:

▪ Brute Force Algorithm: It is the simplest approach for a problem. A brute force algorithm is the first approach that
comes to finding when we see a problem.

21
Python Algorithms
❑ Types of Algorithms:

▪ Recursive Algorithm: A recursive algorithm is based on recursion. In this case, a problem is broken into several sub-
parts and called the same function again and again.

22
Python Algorithms
❑ Types of Algorithms:

▪ Backtracking Algorithm: The backtracking algorithm basically builds the solution by searching among all possible
solutions. Using this algorithm, we keep on building the solution following criteria. Whenever a solution fails we trace
back to the failure point and build on the next solution and continue this process till we find the solution or all possible
solutions are looked after.

23
Python Algorithms
❑ Types of Algorithms:

▪ Searching Algorithm: Searching algorithms are the ones that are used for searching elements or groups of elements
from a particular data structure. They can be of different types based on their approach or the data structure in which
the element should be found.

24
Python Algorithms
❑ Types of Algorithms:

▪ Sorting Algorithm: Sorting is arranging a group of data in a particular manner according to the requirement. The
algorithms which help in performing this function are called sorting algorithms. Generally sorting algorithms are used
to sort groups of data in an increasing or decreasing manner.

25
Python Algorithms
❑ Types of Algorithms:

▪ Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm. But they contain an index with a
key ID. In hashing, a key is assigned to specific data.

26
Python Algorithms
❑ Types of Algorithms:

▪ Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems, solves a single sub-problem and
merges the solutions together to get the final solution. It consists of the following three steps: Divide – Solve -
Combine

27
Python Algorithms
❑ Types of Algorithms:

▪ Greedy Algorithm: In this type of algorithm the solution is built part by part. The solution of the next part is built based
on the immediate benefit of the next part. The one solution giving the most benefit will be chosen as the solution for
the next part.

28
Python Algorithms
❑ Types of Algorithms:

▪ Dynamic Programming Algorithm: This algorithm uses the concept of using the already found solution to avoid
repetitive calculation of the same part of the problem. It divides the problem into smaller overlapping subproblems
and solves them.

29
Python Algorithms
❑ Types of Algorithms:

▪ Randomized Algorithm: In the randomized algorithm we use a random number so it gives immediate benefit. The
random number helps in deciding the expected outcome.

30
Practices (Logistic problems)
Practices (Parallel processing)
question_pop_up_from_box_hg_clr

Start/Stop

Xem xét model:


Input/Output

Do something

Decision

+
-
Practices (Logistic problems)
Xem xét model:
Practices (Logistic problems)
❑ Xem xét model:

➢ Xây dựng mô hình toán mô tả và đề xuất giải pháp.


➢ Vẽ flowchart lập trình chương trình cho Python.
➢ Viết code python thực thi giải thuật/giải pháp đã đề xuất.

Question?
Cần bao nhiêu trucks tối thiểu để vận chuyển hết hàng hóa trong thời gian MỘT tuần?
Với 100 trucks, thời gian tối thiểu cần để vận chuyển hết hang hóa trong warehouse?
Practices: Algorithms
Design of Algorithm in Python Programming

You might also like