Download Characteristics of Algorithms: Definition and Important Features and more Essays (high school) Ancient Greek in PDF only on Docsity!
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 D
Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date:
Lecturer Signature:
- I. Algorithm............................................................................................................................
- Definition of algorithm and characteristics of algorithm.........................................................
- 1.1 Definition of algorithm
- 1.2. Characteristics of algorithm.
- Criteria to measure a good algorithm.
- Steps to build an application...................................................................................................
- 3.1. Defining or Analyzing the problem:
- 3.2. Design (Algorithm):
- 3.3. Coding:
- 3.4. Documenting the program:
- 3.5. Compiling and running the program:
- 3.6. Testing and debugging:
- 3.7. Maintenance:
- Steps from writing code to execution:
- 4.1. In General
- 4.2 In C#
- The relationship between the written algorithm and the code variant..................................
- 5.1. Code variant:
- 5.2. The difference between algorithm and code variant:
- 5.3. The relationship between algorithm and code variant:
- Figure 1: Example Flowchart of an Algorithm.
- Figure 2: Example coding to sum 2 number.
- Figure 3: Example steps to cook rice............................................................................................
- Figure 4: Example An algorithm.
- Figure 5: 7 steps to build an application.
- Figure 6: Writing code to execution in general.
- Figure 7: Writing code to execution in C#
- Figure 8: Flowchart to find a number is even or odd
I. Algorithm
1. Definition of algorithm and characteristics of algorithm. 1.1 Definition of algorithm An algorithm is a method for solving a class of problems step by step. It is a well-defined procedure that allows a computer to solve a mathematical problem or some other problem. Algorithms are capable of performing calculations, data processing, and automated reasoning.
Figure 1 : Example Flowchart of an Algorithm.
Start
Read A
ReadB
Calculate Sum as A+B
Print Sum
End
Find the sum of 163 and 262 Start | | | | A= 163 | | | | B= 262 | | | | Sum= 163+ | | | | Sum= 425 | | | | End
1.2. Characteristics of algorithm.
- There are five important characteristics of an algorithm that should be considered while designing any algorithm for any problem:
- Finiteness : An algorithm should terminate an infinite number of steps in a finite amount of time.
- Definiteness : Each step of algorithm should be clearly and precise define and there should not be any ambiguity. ▪ Example : A program fragment is given below: • X →1. Toss a coin, if result is head then X →3 else x→4. In the above program, all the steps would be carried out effectively but there is no definiteness since there are two possible values of X 1 and ¾.
- Inputs : An algorithm must have zero or more but must be finite number of inputs. Example of zero input algorithm. Print the ASCII code of each of the letter in the alphabet of computer system.
- Output : An algorithm must have at-least one desirable outcome.
- Effectiveness : An algorithm should be effective. Effective means that each step should be referred as principle and should be executing in finite time.
Example: Cook perfectly fluffy rice.
Figure 3 : Example steps to cook rice.
1. Boil water and add salt 2. Pour in rice 3. Stir once, or just enough to separate the rice **4. Cover the pot and
- Fluff rice with a fork simmer**
2. Criteria to measure a good algorithm. A good algorithm is one type of algorithm for solving a specific problem.
- A good algorithm has these criteria:
- Input : There are zero or more quantities which are externally supplied; Output: at least one quantity is produced;
- Definiteness : Each instruction must be clear and unambiguous;
- Finiteness : If we trace out the instructions of an algorithm, then for all cases the algorithm will terminate after a finite number of steps;
- Effectiveness : Ever instruction must be sufficiently basic that its principle be carried out by a person using only pencil and paper.
- Execution time : An algorithm may have good time efficiency but bad space efficiency or an algorithm may have good space efficiency but bad time efficiency. Time efficiency is the time that the algorithm requires to solve a problem and size/space efficiency is the memory size (allocated for variables) that the algorithm requires solve the given problem.
- Size of input data : Generally, algorithms are efficient when small inputs are given, but their efficiency gradually decreases when the size of input is increased. For evaluating the efficiency of your algorithm, you must check the time required for processing by your algorithm for different size of inputs given.
- It is not sufficient for any problem, but it must also contribute to the improvement of an algorithm.
3. Steps to build an application There are 7 steps to build an application:
Figure 5 : 7 steps to build an application.
Defining or Analyzing the problem Design (Algorithm)^ Coding
Testing and Debugging Compiling and running the program
Documenting the program
Maintenance
3.1. Defining or Analyzing the problem:
Before writing the program, the problem must first be understood. The problem must then be analyzed to determine the input and output of the problem solution. This step is critical to the success of a project.
3.2. Design (Algorithm):
With the problem was determined in the first step, there are a lot of way to solve it, but we should analyze and chose the best suitable solution that we are going to design into algorithm. To make the problem unambiguous and understandability, flow charts are drawn with the algorithms.
3.3. Coding:
In programming language, all the logic and solution have been developed with the algorithm.
3.4. Documenting the program:
Documenting the program is the information that describes the product to its users. The documentation informs users about how the program works and how to use it. It helps a developer understand all aspects of an application, such as troubleshooting, database, server environment, and so on. Using programming languages such as C#, C++, Java, and others.
Documentation often comes in two form:
- External documentation : including Reference manuals, Algorithm descriptions, Flowcharts and Project Workbooks.
- Internal documentation : including a part of the source code with declarations, statements and comments to provide an easier understanding.
3.5. Compiling and running the program:
Compiling is a process of translating source code into binary machine code, which make computer can understand and work.
3.6. Testing and debugging:
- Testing: is the process of exploring a system to find software defects. This process must locate the defects and define what will happen if these defects occur. Following this phase, it will report to the developer for debugging. Testing means detecting errors.
- Debugging: When received the report from the testing, it will start debugging to locate the bug and rids the software of it. Debugging means diagnosing and correcting the root causes.
4.2 In C#
- Source code will be parsed to ensure you comply with the Microsoft Intermediate Language (MSIL) code.
Figure 7 : Writing code to execution in C#
C# source code
Microsoft Intermediate Languages (MSIL) code Metadata
Native code, machine code ( Operating System)
OR Uses (.Net Framework Class Libraties)
C# complier
Just-in-time (JIT) compiler
5. The relationship between the written algorithm and the code variant
5.1. Code variant:
- When using the component object model, a variable is a data type in certain programming languages, most notably Visual Basic, Ocaml, Delphi, and C++. Variant aids programmers in the development of algorithms, and code variants are required for machines to understand the algorithm.
- While the use of not explicitly declared variants is not recommended, they can be of use when the needed data type can only be known at runtime, when the data type is expected to vary, or when optional parameters and parameter arrays are desired. In fact, languages with dynamic type system often have variant as the only available type for variables.
5.2. The difference between algorithm and code variant:
- The algorithm is used to solve a problem in the form of well-defined steps. When humans use a computer to solve a problem, and the algorithms can be expressed using natural language, flowcharts, and so on. However, because the variant does not use specific programming language syntax, it can be understood by programmers who use different programming languages.
5.3. The relationship between algorithm and code variant:
- The algorithms can be written in normal human language, allowing experts who are not programmers to provide input into the program's development phase. Code variant allows programmers who specialize in different programming languages to pool their knowledge and create the most efficient code, resulting in fast, compact programs. Each kind of “language” gives the programmer an advantage at the development stage when express their algorithms into code variant to solve solution.
Bibliography
Available at: https://www.quora.com/How-is-a-good-algorithm-Explain-how-to-measure-it- with-example Available at: https://www.quora.com/What-criteria-are-used-to-tell-a-good-algorithm Available at: https://creately.com/blog/diagrams/flowchart-guide-flowchart-tutorial/ Available at: https://www.owlgen.com/question/what-is-an-algorithm-explain-characteristics- of-an-algorithm-with-the-help-of-an-example visual-paradigm Available at: https://www.visual-paradigm.com/tutorials/flowchart-tutorial/ Available at: http://www.computerhope.com/jargon/e/event-driven-prog.htm Available at: https://zakkcuthbertunit14eventdrivenprogramming.wordpress.com/2014/11/07/key- features-of-event-driven-programs/ Available at: https://en.wikipedia.org/wiki/Event-driven_programming#Common_uses Available at: http://www.studytonight.com/cpp/cpp-and-oops-concepts Available at: https://www.techwalla.com/articles/the-difference-between-algorithms- pseudocode-programming-languages
In General
- Coding: This step is translating the design into program which is written in program language.
- Compiling: This is a process make the program written in program language into machine code made
up with 0 and 1 that computer will understand and work. The computer works only understand binary
machine code.
- Debugging: This is a process of finding and fixing the bug in the program.
In C#
- Source code will be parsed to ensure you comply with the Microsoft Intermediate Language (MSIL) code.