




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive introduction to algorithms in software programming, focusing on their importance, advantages, and disadvantages. It uses a practical example of a student grading system implemented in c# to illustrate the application of algorithms in solving real-world business problems. Code examples, flowcharts, and a detailed explanation of the algorithm's implementation, making it a valuable resource for students and professionals interested in learning about algorithms and their practical applications.
Typology: Assignments
1 / 36
This page cannot be seen from the preview
Don't miss anything!
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 RT7 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 D
Feedback:
Grade: Assessor Signature: Date:
Lecturer Signature:
Algorithm is one of the foundations of programming. There are many definitions of algorithms, such as:
Algorithms can be defined as: “A sequence of activities to be processed for getting desired output from a given input.”
Webopedia defines an algorithm as: “A formula or set of steps for solving a particular problem. To be an algorithm, a set of rules must be unambiguous and have a clear stopping point”. There can be many ways to solve a problem, so there can be more than one algorithm for a problem.
Now, if we take the definition of algorithm as: “A sequence of activities to be processed for getting desired output from a given input.” This is why an algorithm refers to a set of rules/instructions that define step by step how to do work to achieve an expected result.
Figure 1. What is algorithm?
Thus, the entire algorithmic flowchart will have three main components:
● Input: What we already know or things we have to start with. ● Algorithm: A set of sequenced steps that we need to follow one by one. ● Output: The expected results we need to achieve in the end.
Algorithms take in zero or more inputs and give back one or more outputs. A recipe is a good example of an algorithm because it tells you what you need to do step by step. It takes inputs (ingredients) and produces an output. For instance, the Coffee Maker Algorithm would run something like
● Turn on Coffee Maker ● Grind Coffee Beans ● Put in filter and place coffee in filter ● Add Water ● Start brewing process ● Drink coffee.
In computer programming, algorithms are often created as functions. These functions serve as small programs that can be referenced by a larger program. For example, an image viewing application may include a library of functions that each use a custom algorithm to render
different image file formats. An image editing program may contain algorithms designed to process image data. Examples of image processing algorithms include cropping, resizing, sharpening, blurring, red-eye reduction, and color enhancement.
Algorithm is developed first before writing the program. By using good algorithms, we can improve the efficiency of the program. Algorithm is not the complete program or code, it is just a solution of a problem or the set of steps that are required to solve a problem, which can be represented either using a Flowchart or Pseudocode.
Donald Ervin Knuth has given a list of five properties for a, algorithm, these properties are:
Figure 2. Properties of algorithm
There are standardized symbols to draw flowcharts. Some are given in Table below.
Flowchart symbol
Function Description
Start/End Also called the “Terminator” symbol. It indicates where the flow starts and ends. Process Also called “Action Symbol”, it represents a process, action, or a single step. Decision A decision or branching point, usually a yes/no or true/false question is asked, and based on the answer, a path gets split into two branches. Input/Output Also called a data symbol, this parallelogram shape is used to input or output data. Arrow Connector to show order of flow between shapes. Figure 3. Shapes or symbol to draw flow charts
Some examples of algorithms.
Example 1 : Write an algorithm to find the square of a number.
Before developing the algorithm, let us first identify the input, process and output:
● Input: Number whose square is required ● Process: Multiply the number by itself to get its square. ● Output: Square of the number.
Algorithm to find the square of a number.
Step 1: Input a number and store it to num
Step 2: Compute num * num and store it in square
Step 3: Print square
There can be represented pictorially using flowchart as shown in Figure below.
Figure 4. Flowchart to calculate square of a number
The below program asks the user to enter the value. After getting the value from the user it will calculate the square of entered number by using arithmetic multiplication operator.
Figure 5. Code to calculate square of a number
And the result:
Figure 6. The result of the algorithm to find the square of a number
Figure 7. Step for problem solving
It is important to clearly understand a problem before we begin to find a solution to it. If it is not clear to us what will be resolved, we may end up developing a program that may not solve our purpose. Therefore, we need to read and analyze the statement carefully to list the main components of the problem and decide what core functions our solution should have. By analyzing a problem, we will be able to figure out what input our program should accept and what output the program should produce.
It is essential to device a solution before writing a program code for a given problem. The solution is represented in natural language and is called an algorithm. We can imagine an algorithm like a very well-written recipe for a dish, with clearly defined steps that, if followed, one will end up preparing the dish.
We start with a tentative solution plan and keep on refining the algorithm until the algorithm is able to capture all the aspects of the desired solution. For a given problem, more than one algorithm is possible and we have to select the most suitable solution.
After finalizing the algorithm, we need to convert the algorithm into the format which can be understood by the computer to generate the desired solution. Different high level programming languages can be used for writing a program.
The program created should be tested on various parameters. The program should meet the requirements of the user. It must respond within the expected time. It should generate correct
output for all possible inputs. In the presence of syntactical errors, no output will be obtained. In case the output generated is incorrect, then the program should be checked for logical errors, if any.
Software industry follows standardized testing methods like unit or component testing, integration testing, system testing, and acceptance testing while developing complex applications. This is to ensure that the software meets all the business and technical requirements and works as expected. The errors or defects found in the testing phases are debugged or rectified and the program is again tested. This continues till all the errors are removed from the program.
Once the software application has been developed, tested and delivered to the user, still problems in terms of functioning can come up and need to be resolved from time to time. The maintenance of the solution, thus, involves fixing the problems faced by the user, answering the queries of the user and even serving the request for addition or modification of features.
To be able to understand more about the algorithm and its details. I will apply an algorithm to solve a problem like this: A teacher wants to manage the final grades of students in the class. He needs to print out the ranking of the students, calculate the average score of the students and calculate the pass rate of the students. The program needs to enter student information, student IDs and grades.
After entering the information, the program needs a Menu so that he can use the functions as a After read clearly the scenario, I solved it by using an algorithm based on C# language to create a program must have full option that satisfy the requirement of teacher. C# is a general object-oriented programming (OOP) language for networking and Web development. C# is specified as a common language infrastructure (CLI) language. In January 1999, Dutch software engineer Anders Hejlsberg formed a team to develop C# as a complement to Microsoft’s NET framework. Initially, C# was developed as C-Like Object Oriented Language (Cool). The actual name was changed to avert potential trademark issues. In January 2000, NET was released as C#. Its NET framework promotes multiple Web technologies.
Here, we need to create an application to enter name, score, ID above.
To solve the above problem, we need the Input and Output integration of the problem. Here, the teacher will enter the student's information and ask the program to print out the student rankings, the grade point average of the class and the passing rate of the students. So, we can summarize the input and output as follows:
● Input: Student's information including ID, name and grade. ● Output: Ranking, GPA and pass rate of students in the class.
name (name), student’s ID (ID), intermediate variable to change student code according to grade arrangement (id). To be clearer, I will create a table of the variables that I use in this program.
Data type Variable Function Integer choice Get user selected silk Double number Declare the number of students sum Calculate the total score of the student count Calculate the number of students who pass the course compare The intermediate variable to sort the student’s score grade Declare student’s grade String ID Declare the ID of the student name Declare the name of the student id The intermediate variable to change the student’s ID according to the score arrangement. Figure 9. Variables and data types
Here, I will use flowchart to show the algorithms that I will use in the system.
The system includes the following features:
Figure 10. Menu of system
Figure 11. Flowchart Main menu
Algorithm (Pseudo code):
Figure 12. Flowchart Input Student
Figure 13. Flowchart Print information of student