ix CHAPTER 1: ALGORITHMS, ISSUES RELATED TO ALGORITHMS AND BASIC PROGRAMMING.... 1 Define basic algorithms to carry out an operation and outline the process of programming an application
Trang 1STUDENT : NGUYEN THANH DAT CLASS > ITO5101
STUDENT ID : BDOO118 SUPERVISOR : NGUYEN HOANG ANH VU
DANANG, JUNE 2022
Trang 2
ASSIGNMENT I FRONT SHEET
Qualification BTEC Level 4 HND Diploma in
Computing Unit number and Unit: Programming
title
Date received
Submission date 16/06/2022 (1stsubmission) 23/06/2022
Date received Re-submission date 23/06/2022 (2ndsubmission) 30/06/2022
Student name NGUYEN THANH D4 Student ID BD00118
Class IT050101 Assessor name NGUYEN HOANG ANH V
Trang 4BTEC =a
First of all, I would like to thank my mentor Nguyen Hoang Anh Vu for his constant support
in my studies and research, for his patience, motivation, enthusiasm and rich knowledge His
ACKNOWLEDGMENTS
guidance has helped me throughout the time of studying and writing this thesis Without your
wonderful help, I would not have been able to achieve this
In addition to my mentor, I would like to thank my friends who have helped me improve
my knowledge of my subject Not only that, they are always there to support me when I need it And besides, I would like to thank the school for creating all conditions for me to have adequate facilities to help me complete my work
Last but not least, I would like to thank my family: my parents who gave birth to me from the beginning and supported me spiritually They are always behind to care and help me have more motivation to complete the work well
11 PERFOMED STUDENT: NGUYEN THANH DAT
Trang 5‘BTEC
‘BT E€ ASSURANCE
I declare that this is my work, based on my research, and that I have recognized all materials and sources utilized in its production, including books, papers, reports, lecture notes, and any other type of document, electronic or personal communication I further declare that I have not previously submitted this assignment for assessment in any other unit, except where explicit permission has been granted by all unit coordinators involved, or at any other time in this unit, and that I have not duplicated or st olen ideas from the work of others in any was
Declaration of the learner
I verify that the work I've submitted for this assignment is all my own, and that all
research sources have been properly credited
Signature of the student: DAT Date: 19/02/2022
Trang 6
BTEC ae
TABLE OF CONTENT
M6005 0883.400000 1 ,.\0.9i9).4020960i5i 111 ill ASSURANCE 15 1V V.).0.190669)006 06005 Vv LIST OF TABLES AND FIGURES - ceeee reece HH HH re vil I0 {6090900060001 55114 ix CHAPTER 1: ALGORITHMS, ISSUES RELATED TO ALGORITHMS AND BASIC PROGRAMMING 1 Define basic algorithms to carry out an operation and outline the process of programming an application (LOL) eee e cece eee eee eee e ree ree cae peereee seca teeeae enaeeeeneenaeens 1
1 Provide a definition of what an algorithm is and outline the process in building an bijMiI<:010:080 0070177 ồ Ö5Ả.ố 1 1.1 Define Algorithms - - sàng HH HH nhiệt 1 1.1.1 Give an example of algorithms in real life eee eee 1 1.2 Ways to demonstrate algorithms «0.0.0.0 ie eee eeeeee enero eters cere teeeneenetees 3 1.2.1 The first way: Using Pseudocode «00.0.0 cece eee creer reenter eerneenerees 3 1.2.2 Forexample: Write a program to check if a number is even or odd 3 1.2.3 The second way: Using flowchart 0.00.00 eee cee crete tetera tees 4 1.2.4 Example: Draw any two flowcharts 000 ce cee eseesceeseecneenneseneeneenneene ness 5 1.3 Characteristic of Algorithms SH HH HH Hee 5 1.3.1 Every algorithm must meet the following basic characferistics: 5 1.3.2 Steps to WrHing Good Algorithms - 2 ccc s2 tere renter ereeteens 6 1.4 Steps in program developmeni - cty 9
2 Determine the steps taken from writing code to execufion (M]) 12 2.1 Topic: Write a program to manage student Ïisis . 12 CONCLUSION | eee cece er ere ee reene ene ce ee reee near nee saeeaeseesaeeseenesnevaeeseeseseesaeeas 17
Trang 7
‘BTEC ae
2050457019-551
vì
Trang 8‘BTEC =a
LIST OF TABLES AND FIGURES
Figure 1-1: Algorithm ch nàng HH HH HH HH HH 1 Figure 1-2: Put the rice in the pOI ng HH TH Hưng 2 Figure 1-3: Washing rice cece cee 2 Figure 1-4: Measure waf€r Ï€V€Ì - ch ng ng ng cư 2 Figure 1-5: Plug In DOWT TH HH nh ng HH kh 3 Figure 1-6: Turn on the butfOnn nhàn ng ng kế 3 Figure 1-7: PseudOCOdE HH TH HH TH TH HH 4 Figure 1-8: Flowchart e.- - 4 Figure 1-9: Flowchart cece ci cescescesseceneesnesneceseeceeeseeseceaessaseaaeeneesesnaessasenteseesnaes 5 Figure 1-10: Problem - kh nàn TH TH ng HH ng gi HH 6 Figure 1-11: Search 6 Figure 1-12: AlgOrithimis - - kh nh TH ng HH nh ng ng như 7 Figure 1-13: Program - c s nh H TgHHnHnHHnit 7 I4) 0020 0i in 8 Figure 1-15: Optimize 01 8 Figure 1-16: AnaÏy§ÏS ch HH ng TH HH HH HH HT HH g 9 IDP))0-0W2E-11.550:):: ỮRiiiidaiÝiiiỔ 9
II )0000139.-.: 0n e 10 Figure I-19: WTit€ a DFOBTAI - Q0 TT nHHH TH HH TH HH Thi 10 Figure 1-20: Íx DTOBTAIN €TTOTS sàng ng ng HH ng tr kế 11 Figure 1-21: Complete DrOBETAIM - 5 22 2x2 22t TH HH Hệ, 11 Figure 1-22: Program mainf†€nance -. - ch ngư 12 Figure 2-1: Search 12 Figure 2-2: Draw flowCharF on ng HH HH HH ni 13 I0 966 13
vil
Trang 9‘BTEC an Be
Figure 2-4: Code 2.0 cece ceeee cee e ne ree eres teeta eeneneesaee sees seeeaeesaeeseseesaeeseenenseeseee 14 I0 16 can 15 Figure 2-6: PrOgTATN €TTOT - ng ng ng nh Hiệp 15 Figure 2- 7: PrOgTAIM sàn ng Ho HH nh 16 4200023009." 16
vill PERFOMED STUDENT: NGUYEN THANH DAT
Trang 10an algorithm and how does it work? Let's find out in this post!
w This report includes the following:
Chapter 1: Algorithms, problems related to algorithms and basic programming
1 Define basic algorithms to perform an operation and outline the process of programming an application
1.1 Provides definition of what an algorithm is and outlines the Application building process
1.2 Identify the steps taken from coding to execution
1.3 State what are the characteristics of the algorithm
1.4 Learn and outline the steps to develop a complete program
Chapter 2: Must be able to determine the knowledge to implement an algorithm and give specific illustrative examples
Test an implementation of an algorithm in a suitable language Evaluate the relationship between the written algorithm and the code variant
Trang 11
:BTEC
‘BTEC
CHAPTER 1: ALGORITHMS, ISSUES RELATED TO ALGORITHMS AND BASIC
PROGRAMMING Define basic algorithms to carry out an operation and outline the process of
programming an application (LO1)
1 Provide a definition of what an algorithm is and outline the process in
building an application (P1)
1.1 Define Algorithms
- Algorithms are a fundamental concept of Mathematics and Informatics In simple terms,
an algorithm can be a finite set of explicit instructions for solving problems that can be
followed to solve problems
Figure 1-1: Algorithm 1.1.1 Give an example of algorithms in real life
1.1.1.1 Some jobs in reality are: cooking rice
Input: Rice, water
Output: Cooked rice
Trang 131.2.1 The first way: Using Pseudocode
- Pseudocode is an inaccurate way to describe programming Pseudocode is simply the implementation of an algorithm in the form of English annotations and informational text Because it does not belong to any programming language, the syntax of pseudocode will not be the same as that of any other programming language
1.2.2 For example: Write a program to check if a number is even or odd
PERFOMED STUDENT: NGUYEN THANH DAT
Trang 14output: the equation has a double solution of -b/(2*a)
else {case delta < @ }
output: the equation has no solution
Figure 1-7: Pseudocode 1.2.3 The second way: Using flowchart
Flowchart is also known as flowchart or process diagram, it is used to represent an algorithm or a process, flowchart represents the work steps in the form of boxes
separated in order by arrows
Symbol Name Function
Indicates any type of internal [| Process operation inside the Processor
or Memory Used for any Input / Output
- (VO) operation Indicates that /““ˆ_ f F the computer is to obtain data
or output results Used to ask a question that can Decision be answered in a binary
format (Yes/No, True/False) Allows the flowchart to be drawn without intersecting Connector lines or without a reverse
Indicates the starting or ending
Terminal of the program, process, or
Trang 151.3.1 Every algorithm must meet the following basic characteristics:
- There are inputs and outputs: some algorithms have to take input values from a certain set, the algorithm will give output values The output values are the solution of the problem
- Accuracy: in the operation steps must be very clear In other words, under the same condition, two processors performing the same step of the algorithm must give the same result
- Correctness: first of all, the algorithm needs to be correct, that is, after entering data,
the algorithm will work and produce the desired results
- Generality: the algorithm can be applied to problems of the same rank or to already solved problems
- Determine the problem Input -> Process -> Output
- Find the data structure representing the algorithm
- Find the algorithm program
- Build test suites
- Optimize the program
PERFOMED STUDENT: NGUYEN THANH DAT
Trang 16‘BTEC —==
1.3.2 Steps to Writing Good Algorithms
Step 1: Ldentify the problem
| t3 => Some! ˆ
4 Identify
Problem
Figure 1-10: Problem Step 2: Find the structure and data for the problem
Trang 17System;
System.Collections Generic System L ng;
Trang 18‘BTEC
Step 5: Check the program
Íc*] thoigian ame ee eer ela
Susing System;
using System.CoLLections Generic;
using 5ysten.Ling, Hello world !
using System.Text;
using System Threading Tasks;
cs.) C:\windows\system32 Wecome to Viet Nam snasespace thoigian /97/2022 10:07:30 SA {
internal class Program
static void in(string[] args)
Trang 19: “BTEC
1.4 Steps in program development
Step 1: Analyze and define the problem
- Analyze to find out the problems and needs of the problem to have solutions to meet those needs The purpose of analysis is to better understand the problem and solve it before developing the program
Figure 1-16: Analysis Step 2: Create a solution (give an algorithm)
- Take the problem and start gathering information, see what the purpose of the algorithm is, are there any obstacles, organize the information and draw the diagram
Algorithm Engineering
Trang 20‘BTEC a
Step 3: Program design
Program design is the steps that programmers have to do before they start coding It is important to make the right notes that will make the program complete more easily There are 3 basic steps such as: learn the program, use the model prototyping tool, develop test data
Figure 1-18: Design Step 4 Code program
- After analyzing and creating a suitable solution, we begin to write the program code according to the design that we did before
Trang 21ý shove ah puuv
Step 5: Debugging the program
- When errors are discovered in the software code that can cause it to not work or hang
We must proceed to fix the program and start running again to check
Trang 22‘BTEC ==
Step 7: Deployment and maintenance
- When the program code has met the requirements, it is ready to be put into operation and available to organizations The code after implementation will need improvement
in the future, so it should be upgraded and maintained as needed
Figure 1-22: Program maintenance
2 Determine the steps taken from writing code to execution (M1)
2.1 Topic: Write a program to manage student lists
Step 1: Read the problem and give the easiest solutions to implement
Figure 2-1: Search
12 PERFOMED STUDENT: NGUYEN THANH DAT
Trang 23‘BTEC
‘BTEC
Step 2: Draw a diagram of the program's functions
/ Enter student information
Enter: ID Enter: Full name Enter: score Enter: Email
|
¥
Save student information
Figure 2-2: Draw flowchart
Trang 24ConsoLeApp28
li:
Oa Scores {
iz aa |
Write() WriteLine("Enter student informatino
Write( "1£ H
ReadLine();
Write("Name: ");
irr Bt Oh Write("Scores F
2 ReadL ine() ; Scores = Parse(st);
Write("Email H ReadL ine(};
Figure 2-4: Code 2
14
Trang 25ÍE*] student ~ _ ft$ConsoleApp20.StudentList
System;
System CoLLections Generic;
1 ConsotLeApp28
write()
sd.Write() List Add(sd Write("Do you want to enter more? (y/n): ")
Entire Solution © 5 Errors
Trang 26
Figure 2-8: Update
16 PERFOMED STUDENT: NGUYEN THANH DAT
Trang 27‘BTEC ae
CONCLUSION
After completing this report, I have a better understanding of algorithms, how to draw
a flowchart and how to execute a program It helps me better understand how the surrounding devices work I feel very interesting because I learned the things in the report Thank you so much my mentor
17 PERFOMED STUDENT: NGUYEN THANH DAT
Trang 28‘BTEC
REFERENCES
18