You are on page 1of 17

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 1: Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Student ID

Class Assessor name

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:

Grade: Assessor Signature: Date:


Lecturer Signature:
Table of Figure

Ⅰ. 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. ....................................... 7
3. Demonstrate the compilation and running of a program. ...................................................................... 10
4. Evaluate how the problem is solved from the designed algorithm to the execution program written by
a specific programming language.................................................................................................................... 12
Ⅲ. Conclusion ..................................................................................................................................................... 13
Ⅳ. Reference list ................................................................................................................................................. 15

Image Table of Contents

Figure 1: Algorithm ................................................................................................................................................. 2


Figure 2: Illustrating the flow of an algorithm, such as a flowchart or pseudocode representation. ...................... 5
Figure 3: Flowchart representation of the algorithm. ............................................................................................. 9
Figure 4: Example of a basic program running on Visual Studio............................................................................ 11

1
Ⅰ. Introduction:

Figure 1: Algorithm

An algorithm is a step-by-step procedure or set of rules designed to solve a specific problem


or accomplish a particular task. It is a fundamental concept in computer science and plays a
crucial role in solving complex problems efficiently.

2
Algorithms provide a systematic approach to problem-solving by breaking down a problem
into smaller, more manageable steps. These steps are designed to be precise and
unambiguous, ensuring that anyone following the algorithm can reach the desired outcome.

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.

Algorithms can be represented in various forms, such as pseudocode, flowcharts, or


programming code. Pseudocode is a simplified and human-readable form of code that
describes the algorithm's logic without adhering to a specific programming language.
Flowcharts use visual symbols and arrows to depict the flow of operations in an algorithm,
making it easier to understand and analyze.

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

The analysis of algorithms is another crucial aspect of algorithm design. It involves


evaluating the efficiency and performance characteristics of algorithms, such as their time
complexity (how long it takes to run) and space complexity (how much memory they
require). This analysis allows us to compare different algorithms and choose the most
suitable one for a particular problem, considering factors like input size and available
resources.

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

3
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.

Ⅱ. 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.
 Algorithm Overview:

An algorithm is a step-by-step procedure or set of rules designed to solve a specific problem


or accomplish a specific task. It is essentially a well-defined sequence of instructions that
can be followed to solve a problem, perform a calculation, or achieve a desired outcome.
Algorithms can be represented in various forms, such as pseudocode, flowcharts, or
programming code.

4
Figure 2: Illustrating the flow of an algorithm, such as a flowchart or pseudocode representation.

 Explanation:

In the context of sorting algorithms, these are procedures designed to arrange elements in a
specific order. For example, sorting algorithms like Selection Sort, Bubble Sort, and
Insertion Sort are commonly used to rearrange a list of numbers in ascending or descending
order. These algorithms follow a specific set of steps to compare and swap elements until
the desired order is achieved.

 Example:

Let's consider a simple problem of sorting a list of numbers in ascending order using the
Bubble Sort algorithm. Suppose we have the following list of numbers: [5, 2, 8, 3, 1].

1. Starting from the first element, compare each pair of adjacent numbers.
2. If the current number is greater than the next number, swap them.
3. Repeat this process until no more swaps are needed (indicating that the list is sorted).

Using the Bubble Sort algorithm, we would perform the following comparisons and swaps:

5
Pass 1: [2, 5, 3, 1, 8]

Pass 2: [2, 3, 1, 5, 8]

Pass 3: [2, 1, 3, 5, 8]

Pass 4: [1, 2, 3, 5, 8]

After four passes, the list is sorted in ascending order: [1, 2, 3, 5, 8].

By employing sorting algorithms like Bubble Sort, we can efficiently organize data, making
it easier to search, analyze, or present information. Algorithms provide a systematic approach
to problem-solving, ensuring consistent and reliable results.

Next, let's consider a small and simple problem that can be solved using an algorithm. One
such problem is searching for a specific element in a list of numbers.

 Problem: Searching for an Element in a List


 Description: Suppose we have a list of numbers, and we want to determine if a particular
number is present in the list and, if so, at which position it occurs.

Need for Solution: This problem arises in various scenarios, such as finding a specific value
in a database, searching for a word in a document, or locating an item in an array. By solving
this problem efficiently, we can save time and resources, especially when dealing with large
datasets.

Algorithm Solution: Binary Search

Binary Search is an algorithm commonly used for searching elements in a sorted list. It
follows a divide-and-conquer approach by repeatedly dividing the list in half and narrowing
down the search range until the target element is found or determined to be absent.

 Example: Let's consider a sorted list of numbers: [1, 3, 5, 7, 9, 11, 13]. We want to search
for the number 7 in this list.
1. Start with defining the lower and upper bounds of the search range.
2. Calculate the middle index as (lower bound + upper bound) / 2.
3. Compare the middle element with the target element.

6
4. If they match, the search is successful, and the position of the target element is
determined.
5. If the middle element is greater than the target element, update the upper bound to be the
middle index - 1 and repeat steps 2-4.
6. If the middle element is less than the target element, update the lower bound to be the
middle index + 1 and repeat steps 2-4.
7. Continue this process until the target element is found or the search range is exhausted.

In our example, the algorithm would perform the following steps:

Initial range: lower bound = 0, upper bound = 6

First iteration: middle index = (0 + 6) / 2 = 3

Comparison: list [3] = 7 (matches the target element)

Search successful: position of 7 in the list is 3.

By using the Binary Search algorithm, we can efficiently locate elements in a sorted list,
reducing the time complexity compared to linear search algorithms. Algorithms like Binary
Search are valuable tools for solving a variety of search-related problems across different
domains.

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.

 Problem Analysis and Solution Design:


Business Problem: Inventory Management
Application Requirements:
1. Ability to track inventory levels for different products.
2. Accurate calculation of demand for each product.
3. Calculation of ordering costs and holding costs.

7
4. Determination of optimal order quantity for each product.
5. Generation of replenishment orders based on inventory levels and optimal order quantity.

Algorithm Design: Economic Order Quantity (EOQ)

To solve the inventory management problem, we will design an algorithm based on the
Economic Order Quantity (EOQ) approach. The algorithm will calculate the optimal order
quantity for each product, considering the demand, ordering costs, and holding costs.

8
 Here's a flowchart representation of the algorithm:

Figure 3: Flowchart representation of the algorithm.

 Explanation of the Flowchart:


1. Start the algorithm.
2. Input the annual demand, ordering cost, and holding cost for the product.

9
3. Calculate the EOQ using the formula: EOQ = sqrt((2 * Annual Demand * Ordering Cost)
/ Holding Cost).
4. Output the EOQ value.
5. Determine the reorder point, which indicates when to place a replenishment order.
6. Output the reorder point value.
7. Check the current inventory level.
8. If the inventory level is below the reorder point, generate a replenishment order for the
EOQ quantity.
9. Output the replenishment order.
10. End the algorithm.
 The flowchart represents the step-by-step process of the EOQ algorithm. It takes input
values, calculates the EOQ, determines the reorder point, checks the inventory level, and
generates replenishment orders when necessary.
 By following this algorithm, the business can effectively manage its inventory, ensuring
optimal stock levels and minimizing costs. The algorithm provides a systematic and data-
driven approach to decision-making, allowing the business to streamline its inventory
management process.
 Note: The flowchart provided is a simplified representation of the algorithm. Depending
on the specific requirements and complexities of the business, the algorithm may need to
be further refined and expanded.
 Overall, the EOQ algorithm, as depicted in the flowchart, provides a visual representation
of the step-by-step process involved in optimizing inventory levels and generating
replenishment orders based on calculated values.
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?

10
Figure 4: Example of a basic program running on Visual Studio.

 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.
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:

11
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.

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

12
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.

Ⅲ. 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.

We began by providing an overview of algorithms, explaining that they are step-by-step


procedures designed to solve specific problems. Algorithms are crucial in organizing and

13
optimizing processes, making them an essential component of problem-solving in various
domains.

We discussed two common types of algorithms: sorting algorithms and searching algorithms.
Sorting algorithms such as Selection Sort, Bubble Sort, and Insertion Sort help arrange data
in a particular order, while searching algorithms like Linear Search and Binary Search aid in
finding specific elements within a dataset.

To further analyze the problem-solving process, we designed algorithms using suitable


diagrams such as flowcharts or activity diagrams. These visual representations provide a
clear understanding of the algorithm's logic and flow, facilitating the implementation phase.

Next, we demonstrated the implementation of the algorithms in specific programming


languages like C, C++, and C#. By providing code examples and explaining the compilation
and execution process, we illustrated how algorithms can be translated into executable
programs.

Furthermore, we emphasized the importance of testing to ensure the correctness of the


implemented algorithms. Test plans with well-defined test cases are essential to validate the
algorithm's behavior under various scenarios, including normal and boundary cases. Through
rigorous testing and evaluation, we can identify and address any issues or discrepancies,
leading to improved algorithmic solutions.

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
in programming languages, and conducting thorough testing, businesses can leverage the
power of algorithms to drive innovation and success.

In conclusion, algorithms form the cornerstone of problem-solving in the modern business


landscape, enabling organizations to tackle challenges, optimize processes, and make data-
driven decisions for sustainable growth and success.

14
Ⅳ. 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/

15

You might also like