Professional Documents
Culture Documents
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.
P1 M1 D1
❒ Summative Feedback: ❒ Resubmission Feedback:
I. Introduction............................................................................................................................................................3
II. Content.................................................................................................................................................................. 5
1. State your simple business problems to be solved...........................................................................................5
2. Analyze the problem and design the solutions by the use of suitable methods..............................................8
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
III. Conclusion.........................................................................................................................................................13
1
I. Introduction
Figure 1: Algorithms
Sorting algorithms are crucial in organizing data in software products, particularly in e-commerce
websites. These algorithms help in sorting products based on different criteria such as price,
popularity, or relevance. Sorting algorithms are also useful in other industries, such as finance
and healthcare, where data needs to be sorted and organized efficiently.
In finance, sorting algorithms are used to analyze stock market trends and financial data. This
helps in identifying patterns and making informed decisions about investments. In healthcare,
sorting algorithms are used to organize patient records and medical data, making it easier for
healthcare professionals to
2
access and analyze information. Sorting algorithms are crucial in organizing data in software
products, particularly in e-commerce websites. These algorithms help in sorting products based
on different criteria such as price, popularity, or relevance. Sorting algorithms are also useful in
other industries, such as finance and healthcare, where data needs to be sorted and organized
efficiently.
In finance, sorting algorithms are used to analyze stock market trends and financial data. This
helps in identifying patterns and making informed decisions about investments. In healthcare,
sorting algorithms are used to organize patient records and medical data, making it easier for
healthcare professionals to access and analyze information.
Another important algorithm is the shortest path algorithm. This algorithm is commonly used in
navigation software and applications related to the transportation industry, such as Google
Maps, Grab, Uber, and fast delivery services. It helps in finding the shortest path between two
points, in terms of distance or minimum cost. The algorithm is also utilized in network systems
and telecommunication to direct signal transmission. For example, phone calls and internet data
from a computer to the network provider's server use this algorithm to achieve maximum speed.
The search algorithm is another famous algorithm that is used in many current software
products. An excellent example of this is Google, which uses a powerful search algorithm that
enables users to find the information they are looking for within seconds. The search algorithm is
used to search through vast amounts of data to find relevant information, and it is still being
improved to this day.
Encryption algorithms are also essential in protecting personal and organizational information
from attacks or exploitation. They are used to encrypt information during transmission and
storage of data. This helps in safeguarding sensitive information from unauthorized access.
In software development, you may encounter small problems or issues that require you to
choose the right solution algorithm to solve them. For instance, you may need to find a computer
priced from X to Y that meets the user's maximum criteria in just one click. You may also need to
come up with products or articles that users are interested in based on their browsing history.
However, as you progress in programming, you may encounter more challenging problems that
require advanced algorithms to solve. During product development, teams may have to solve
complex problems such as calculating and sorting user's rank based on study and test history,
count the number of user hits in a period to predict the attack, or provide suggestions for
exercises that users should do based on their access and operation history on the system.
These problems may seem daunting, especially when dealing with large amounts of data and
users. However, choosing the right algorithm can significantly improve processing speed and
efficiency, making it easier to solve complex problems.
In summary, algorithms are essential in software development, and they help in solving complex
problems efficiently. Choosing the right algorithm can significantly improve processing speed
and efficiency, making it easier to handle large amounts of data and users.
3
It is worth noting that the selection of algorithms is not always straightforward. One must
consider the trade-offs between the accuracy of the results, the speed of the algorithm, and the
amount of memory required for implementation. In some cases, the best algorithm for a
particular problem may not be immediately apparent, and developers may need to experiment
with different algorithms to find the best fit.
Moreover, algorithms are not static entities. They are subject to change and evolution as new
challenges arise and new technologies become available. Developers must stay up to date with
the latest developments in algorithm design to ensure that their software remains competitive
and efficient.
Finally, it is essential to remember that algorithms do not exist in a vacuum. They are part of a
broader software development process that involves everything from requirements gathering to
testing and maintenance. As such, developers must consider how algorithms fit into the overall
architecture of their software and the needs of their users.
II. Content:
1. State your simple business problems to be solved.
4
Figure 2: Algorithm example
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].
5
• (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,
6
- Sorting Algorithm: Bubble Sort
+ Bubble sort is a basic algorithm for arranging a string of numbers or other elements
in the correct order. The method works by examining each set of adjacent elements in the string,
from left to right, switching their positions if they are out of order. The algorithm then repeats this
process until it can run through the entire string and find no two elements that need to be
swapped.
Here's a step-by-step description of how it works:
1. Start by comparing the first two elements of the list. If the first element is greater than the
second element, swap them. If not, leave them as they are.
2. Move on to the next pair of adjacent elements and repeat step 1.
3. Continue this process until you reach the end of the list. At this point, the largest element in
the list will have "bubbled up" to the end of the list.
4. Repeat steps 1-3, but this time only iterate through the unsorted elements. This means
that the last element of the list is now sorted and does not need to be compared again.
Bubble sort is not the most efficient sorting algorithm, as it has a worst-case time complexity of
O(n^2). However, it is easy to understand and implement, and can be useful for small lists or as
a stepping stone to more advanced sorting algorithms.
+ Binary search is an efficient algorithm that searches a sorted list for a desired, or
target, element. For example, given a sorted list of test scores, if a teacher wants to determine if
anyone in the class scored 8080, she could perform a binary search on the list to find an answer
quickly. Binary search works by halving the number of elements to look through and hones in on
the desired value. Binary search can determine if and where an element exists in a list, or
determine if it is not in the list at all.
7
3. Check if the target value is equal to the middle element of the array. If it is, return
the index of the middle element.
4. If the target value is less than the middle element, move the end pointer to the
middle index - 1. This narrows the search to the lower half of the array.
5. If the target value is greater than the middle element, move the start pointer to the
middle index
+ 1. This narrows the search to the upper half of the array.
6. Repeat steps 2-5 until the target value is found or the pointers cross each other.
The binary search algorithm has a time complexity of O(log n), which makes it a very efficient
search algorithm for large arrays. However, it only works on sorted arrays, which can be a
limitation in some cases.
* For example :
- How to Cook Rice
1. Accurately measure the amount of water
8
2. Put a little oil in the pot.
3. Turn on the stove to adjust the temperature to moderate and heat the cooking oil, then put the
rice in the pot.
9
5. Add water and bring to a boil.
10
7. Small fire
11
9. Finished rice dish.
- You need to gather information about the business problem and understand the requirements
of the application to be developed. Then, you can start designing the algorithm using suitable
diagrams such as Flowchart, Activity Diagrams, etc. The algorithm should be designed in such a
way that it solves the business problem effectively and efficiently.
12
Figure 3: Marth Flowchart
operation, where the program reads the next number from the input.
point. The program checks if the input number is greater than the current
13
5. Yes: If the input number is greater than max-min, the program takes the path
6. No: If the input number is not greater than max-min ,the program takes
operation, where the program reads the next number from the input.
read.
9. Yes: If there is another number available, the program takes the path
labeled "Yes" and returns to step 4 to compare the new number with
10.No: If there are no more numbers available, the program takes the
output operation, where the program displays the value of max-min as the
1. In Solution Explorer, in the right pane, select Program.cs to display the file in the code editor
14
2. In the code editor, replace the default "Hello World" code that says Console.WriteLine("Hello
World!")
Figure 4: Step 1
3. To build and run your app, press F5, or select the green arrow next to the name Calculator
in the top toolbar:
Figure 5: Step 2
A console window opens that shows the sum of 42 + 119, which is 161.
15
Figure 6: Result
5.Optionally, you can change the operator to change the result. For example, you can change the +
operator in the int c = a + b; line of code to - for subtraction, * for multiplication, or / for division. When you
run the app, the result changes accordingly.
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.
1. Algorithm Design:
The algorithm for solving the problem of finding the sum of even numbers in a given
list is as follows:
+ Initialize a variable sum to 0.
+ Iterate through each element in the list.
+ Check if the element is even (i.e., divisible by 2 with no remainder).
+ If the element is even, add it to the sum.
+ Finally, return the sum.
2. Execution Program (C#):
Here's an implementation of the algorithm in C#:
16
Figure 7: implementation of the algorithm in C#
III. 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 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.
17