Bùi Thái Dương
Bùi Thái Dương
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P1 M1 D1
❒ Summative Feedback: ❒ Resubmission Feedback:
Ⅰ. Introduction:.....................................................................................................................................................2
Ⅱ. Content:...........................................................................................................................................................4
1. State your simple business problems to be solved.......................................................................................4
2. Analyze the problem and design the solutions by the use of suitable methods........................................11
3. Demonstrate the compilation and running of a program.........................................................................13
4. Evaluate how the problem is solved from the designed algorithm to the execution program written by
a specific programming language.......................................................................................................................15
Ⅲ. Conclusion....................................................................................................................................................16
Ⅳ. Reference list................................................................................................................................................17
Figure 1: Algorithm................................................................................................................................................2
Figure 2: Algorithm example....................................................................................................................................5
Figure 3 :Flowchart representation of the Bubble sort algorithm.........................................................................8
Figure 4: Description of the Binary Search algorithm..........................................................................................10
Figure 5: Algorithm is described by flowchart to solve the problem...................................................................11
Figure 6: Example of a basic program running on Visual Studio........................................................................13
1
Ⅰ. Introduction:
Figure 1: Algorithm
The importance of algorithms lies in their ability to optimize processes and improve
efficiency. They enable us to solve problems more quickly and effectively, even with large
amounts of data or complex operations.
There are different types of algorithms, each suited for specific tasks. Sorting algorithms,
such as Selection Sort, Bubble Sort, and Merge Sort, arrange elements in a specific order.
Searching algorithms, like Linear Search, Binary Search, and Hashing, help locate specific
2
elements within a dataset. Graph algorithms, such as Depth-First Search and Dijkstra's
algorithm, analyze relationships and connections between objects.
Algorithms are not limited to the realm of computer science; they have applications in
various other fields as well. In mathematics, algorithms are used to solve equations, find
prime numbers, or calculate complex functions. In logistics and optimization, algorithms
help determine the most efficient routes for delivery or scheduling tasks. They are also
used in cryptography to secure data and communications.
As technology continues to advance, algorithms play a vital role in shaping our modern
world. They underpin innovations in artificial intelligence, machine learning, and data
science, enabling us to make sense of vast amounts of information and make data-driven
decisions.
Learning about algorithms provides valuable problem-solving skills and enhances logical
thinking. It equips individuals with the ability to approach challenges systematically and
develop efficient solutions.
In conclusion, algorithms are fundamental tools for solving problems and accomplishing
tasks in various domains. They provide a systematic and efficient approach to problem-
solving, facilitating advancements in technology and improving our daily lives.
Understanding and utilizing algorithms empower us to tackle complex problems effectively
and drive innovation in an increasingly digital world.
3
Ⅱ. Content:
1. State your simple business problems to be solved.
First, you need to provide an overview about Algorithm with image illustration,
explanation and example.
Next, you will have to represent a small and simple problem, why it is needed to be
solved and how an algorithm could help to solve it. It could be a simple problem such
as:
- Sorting Algorithm: Selecting Sort, Bubble Sort, Insertion Sort, etc.
- Searching Algorithm: Linear Search, Binary Search, etc.
4
Example Code in C#:
5
Given array: [5, 2, 9, 1, 3]
2. First Pass:
In the outer loop, we start from the first element (5) and iterate until the last element.
In the inner loop, we compare each adjacent pair of elements and swap them if they are
in the wrong order.
(5, 2): Since 5 is greater than 2, they are swapped. The array becomes [2, 5, 9, 1, 3].
(5, 9): No swap needed.
(9, 1): Since 9 is greater than 1, they are swapped. The array becomes [2, 5, 1, 9, 3].
(9, 3): Since 9 is greater than 3, they are swapped. The array becomes [2, 5, 1, 3, 9].
In this pass, the largest element (9) moves to the end of the array.
3. Second Pass:
In the outer loop, we start from the first element (2) and iterate until the second-to-last
element.
In the inner loop, we compare each adjacent pair of elements and swap them if they are
in the wrong order.
(2, 5): No swap needed.
(5, 1): Since 5 is greater than 1, they are swapped. The array becomes [2, 1, 5, 3, 9].
(5, 3): Since 5 is greater than 3, they are swapped. The array becomes [2, 1, 3, 5, 9].
In this pass, the second-largest element (5) moves to its correct position.
4. Third Pass:
In the outer loop, we start from the first element (2) and iterate until the third-to-last
element.
In the inner loop, we compare each adjacent pair of elements and swap them if they are
in the wrong order.
(2, 1): Since 2 is greater than 1, they are swapped. The array becomes [1, 2, 3, 5, 9].
In this pass, the third-largest element (3) moves to its correct position.
After sorting: The sorted array is displayed: [1, 2, 3, 5, 9]
6
The Bubble Sort algorithm repeatedly compares adjacent elements and swaps them if
they are in the wrong order. This process is repeated for each pair of adjacent elements
until the entire array is sorted in ascending order.
Bubble sort is often chosen when the list of elements to be sorted is small or when
simplicity is preferred over efficiency. It is a simple sorting algorithm that repeatedly
steps through the list, compares adjacent elements, and swaps them if they are in the
wrong order. This process is repeated until the entire list is sorted.
Here is the step-by-step description of the Bubble sort algorithm:
1. Start at the beginning of the list.
2. Compare the first element with the second element.
3. If the first element is greater than the second element, swap them.
4. Move to the next pair of elements (second and third) and repeat the comparison and
swapping if necessary.
5. Continue this process until the last two elements of the list are compared and swapped if
needed.
6. After the first pass, the largest element will be in its correct position at the end of the
list.
7. Repeat steps 1-6 for the remaining elements, excluding the last one (which is already
sorted).
8. Continue these passes until the entire list is sorted.
7
Flowchart representation of the Bubble sort algorithm:
The description of the Bubble Sort algorithm using the flowchart is as follows:
1. Start the algorithm.
2. Enter the loop to iterate over the array elements.
3. Compare adjacent elements.
4. If the elements are out of order (not in ascending order), proceed to the swap step.
5. Swap the elements to put them in the correct order.
6. Check if the loop has reached the end of the array.
7. If the end has not been reached, repeat the loop from step 3.
8. If the end has been reached, proceed to the end step.
8
9. End the algorithm.
Binary Search is a suitable algorithm when you have a sorted list/aray and you want to
efficiently search for a specific element. It is particularly useful when dealing with large
datasets or when the cost of accessing elements is high.
9
Figure 4: Description of the Binary Search algorithm
10
2. Analyze the problem and design the solutions by the use of suitable methods.
In this part, you will have to analyze the business problem and turn it into application
requirements. Then, you will need to design the algorithm to solve the problem by
using suitable diagrams such as Flowchart, Activity Diagrams, etc.
11
1. Start: The flowchart begins here.
This flowchart represents an algorithm to find the largest number in a list of integers. The
algorithm iterates through the list, comparing each number with the current maximum and
updating the maximum if a larger number is found. The process continues until all numbers
have been examined, and then the largest number is displayed as the output.
12
3. Demonstrate the compilation and running of a program.
Next, you have to demonstrate how the application is implemented by using suitable
programming language. Source code and screenshots of the program have to be
included with clear explanations.
You need also explain briefly what is Software Development Life Cycle and how the
source code is compiled and run?
Here's how you can compile and run this program using Visual Studio:
1. Open Visual Studio and create a new project (e.g., a "Console App" project).
2. Copy the above code into the main source file of your project (e.g., Program. cs).
3. Build the project by pressing the "Ctrl + Shift + B" key combination or selecting
"Build" > "Build Solution" from the menu.
13
4. If the build is successful, you should see "Build succeeded" in the output window.
5. Run the program by pressing the "Ctrl + F5" key combination or selecting "Debug" >
"Start Without Debugging" from the menu.
6. The console window will appear, prompting you to enter the first and second numbers.
7. After entering the numbers, the program will calculate the sum and display the result.
Software Development Life Cycle (SDLC):
The Software Development Life Cycle is a structured approach to developing software
applications. It consists of several phases:
1. Requirements Gathering: Gather and analyze the requirements for the software
application, identifying the desired functionality, user expectations, and constraints.
2. Design: Based on the requirements, design the software architecture, database structure,
user interfaces, and other components. This phase focuses on creating a blueprint for the
software application.
3. Development: Implement the design by writing the source code for the software
application. Developers follow coding best practices, naming conventions, and modular
design principles to ensure maintainability and readability.
4. Testing: Conduct various levels of testing, including unit testing, integration testing,
and system testing. The goal is to identify and fix any defects or issues in the software
to ensure its quality and reliability.
5. Deployment: Prepare the software for deployment by packaging it, creating installation
files, and documenting the necessary instructions for installation and configuration.
6. Maintenance: Once the software is deployed, ongoing maintenance and support are
required. This includes bug fixes, updates, and addressing user feedback or
requirements changes.
Throughout the SDLC, project management techniques, version control systems, and
collaboration tools are used to ensure effective development and successful delivery of
the software application.
I hope this explanation provides you with a general understanding of the compilation
and execution process, as well as the Software Development Life Cycle. If you have
any specific questions or require further assistance, please let me know.
4. Evaluate how the problem is solved from the designed algorithm to the execution
program written by a specific programming language.
14
In this part, you need to demonstrate how the problem is solved by using the
application. Test plan with test cases needs to include to make sure that the algorithm
works properly.
To evaluate how the problem is solved from the designed algorithm to the execution
program, we can follow these steps:
1. Algorithm Design: The first step is to design the algorithm that solves the problem. This
involves breaking down the problem into smaller steps and defining the logic and flow
of the solution. This can be represented using various diagrams like flowcharts,
pseudocode, or activity diagrams.
2. Implementation in a Specific Programming Language: Once the algorithm is designed,
it needs to be implemented in a specific programming language. In our case, let's
assume we have implemented the algorithm in C# using Visual Studio.
3. Test Plan and Test Cases: To ensure that the algorithm and program work properly, a
test plan with test cases should be created. The test plan outlines the testing approach
and objectives, while test cases are specific scenarios or inputs designed to validate the
correctness and efficiency of the algorithm. Test cases should cover different possible
scenarios, including both normal and boundary cases.
4. Execution and Evaluation: The program is executed using the test cases from the test
plan. The input values for each test case are provided, and the program's output is
compared against the expected output. The program's behavior is evaluated based on
whether it produces the expected results and handles different cases correctly.
5. Debugging and Refinement: If any issues or discrepancies are found during testing, the
program is debugged to identify and fix the problems. This may involve reviewing the
algorithm, checking the code for errors, and making necessary modifications. The
program is refined until it produces the expected results for all test cases.
By following this process, we can evaluate how the problem is solved from the designed
algorithm to the execution program. It ensures that the algorithm is correctly translated into
code, and the program behaves as expected. The test plan and test cases help validate the
accuracy and effectiveness of the algorithm, and any issues can be identified and resolved
through debugging and refinement.
15
Ⅲ. Conclusion
In conclusion, algorithms play a crucial role in solving various business problems
efficiently and effectively. Throughout this analysis, we explored the concept of
algorithms, their importance, and how they can be applied to simple problems.
Overall, algorithms serve as powerful tools for solving business problems by providing
systematic and efficient solutions. They are the backbone of computational thinking and
enable businesses to streamline processes, improve efficiency, and achieve desired
outcomes. By understanding algorithms, designing effective solutions, implementing them
16
in programming languages, and conducting thorough testing, businesses can leverage the
power of algorithms to drive innovation and success.
Ⅳ. Reference list
Introduction:
- https://tailieu.vn/doc/gioi-thieu-ve-thuat-toan-trong-tin-hoc-133449.html
- https://cuuduongthancong.com/atc/1190/phan-i-%E2%80%93-gioi-thieu-ve-thuat-toan
- https://www.toponseek.com/blogs/lich-su-thuat-toan-google/
17