You are on page 1of 15

Assignment 1 – 1618

Unit 1: Programming
BY: NGUYEN CHAU TOAN ID: GCD210174
CLASS: GCD1102 ASSESSOR NAME: NGUYEN VAN LOI
Table of Contents
I. Overview about Algorithm with image illustration, explanation and example

1. What is an Algorithm?

2. Example an Algorithm

2.1. Searching Algorithm

2.2. Sorting Algorithm

2.3. Represent a small, simple problem and solve this problem

II. Analyze the problem and design the solutions by the use of suitable methods

1. Analyze the problem

2. Flowchart

III. Demonstrate the compilation and running of a program

1. Introduce how the problem is solved

2. Source code and screenshots of the final result

3. Explain how the source code is compiled


I. Overview about Algorithm with image
illustration, explanation and example
1. What is an Algorithm?
An algorithm is a set of directions for performing a task. For
achieving a mission. For solving a problem, an algorithm can be
understood as a finite set of explicit instructions that the
problem solver can follow to solve the problem. Thus, the
Algorithm is a method of expressing the problem's solution - the
concern.
In programming, there are six popular types of Algorithm:
Search Algorithm, Sort Algorithm, Link Analysis, Integer
Factorization, Fourier Transform Algorithm, String Matching, and
Pass Algorithm.
I. Overview about Algorithm with image
illustration, explanation and example
2. Example Algorithms
2.1. Searching Algorithm
Linear search: This is a simple Algorithm in all search
Algorithm. In this type of search, the search process takes
place continuously. Each element is checked, and if any
match is found, that particular element is returned; If not
found, the search continues until all data is found.
2.2. Sorting Algorithm
Selection sort: is a sorting algorithm that selects the
smallest element from an unsorted list in each iteration
and places that element at the beginning of the unsorted
list.
I. Overview about Algorithm with image
illustration, explanation and example
2.3. Represent a small, simple problem and solve this problem
- I have a quadratic equation (𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0) and three coefficient a = 4, b = -20 and c = 28.
- However, I don’t know how to find x.
- So, I will solve this problem with an algorithm, and it will help me break it down into different
cases.
- Moreover, make my coding easier.
II. Analyze the problem and design the solutions
by the use of suitable methods
1. Analyze the problem
In this regard, I divide it into the following cases:
• a = 0, b = 0, c ≠ 0
The equation hasn’t solution.
• a = 0, b ≠ 0, c ≠ 0
The equation has a unique solution: x = -c / b
• a, b, c = 0
The equation has infinitely many solutions.

• a ≠ 0: In this situation, we go to find delta


Delta = b2 – 4ac, and we have three different case.
- Delta < 0: The equation hasn’t solution
- Delta > 0: The equation distinct solution (-b ± b2 – 4ac) / 2a
- Delta = 0: Equation with double roots x1 = x2 = -c / 2a
II. Analyze the problem and design the solutions
by the use of suitable methods
2. Flowchart
III. Demonstrate the compilation and running of a
program
1. Introduce how the problem is solved
I make a small and simple program, then I will input 3 coefficients a = 4, b = -20, c = 28. Then the
program will help me to give the correct result. My little program is completed in C#
programming language.
III. Demonstrate the compilation and running of a
program
2. Source code and screenshots of the final result
- The first part is to enter the coefficients
III. Demonstrate the compilation and running of a
program
- The second part is to considers coefficients and delta using if-else statement
III. Demonstrate the compilation and running of a
program
- The result after entering three coefficients
III. Demonstrate the compilation and running of a
program
3. Explain how the source code is compiled
Source Compiler Object file
A compiler takes the program code (source code) code
and converts the source code to a machine
language module (called an object file). Another
specialized program, called a linker, combines this
object file with other previously compiled object Runtime Linker
files (particularly run-time modules) to create an library files
executable file.

Executable
file
References

https://www.geeksforgeeks.org
https://www.w3resource.com
http://www.conceptdraw.com
<3 THANK YOU EVERYONE FOR LISTENING <3
“\_( c _ o )_/”

You might also like