Docsity

Algorithms and Programming: A Comprehensive Guide - Prof. Nam, Schemes and Mind Maps of Animal Anatomy and Physiology

Toggle sidebar
bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
10/06/2023
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
M1
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Algorithms and Programming: A Comprehensive Guide - Prof. Nam and more Schemes and Mind Maps Animal Anatomy and Physiology 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 10/06/2023^ 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:

Table of contents

  • I. Introduction
    • P1
  • II. Content
      1. Algorithm
      • a. What is the algorithm ?..............................................................................................................................
      • b. Algorithmic characteristics
      • c. Algorithm example.....................................................................................................................................
      • d. Example in math or programming
      1. Steps to build an app
      • a. Problem definition
      • b. Design program
      • c. Program
      • d. Test and debugging
      • e. Program documentation
      • f. Program implementation and maintenance
      • g. Introduction to Visual Studio
      1. Solve problems using algorithms
      • a. Content of the problem
      • b. Problem analysis
      • c. Flowchart
      • d. Workaround (M1)
      • e. Debug.......................................................................................................................................................
      • f. Test case
    • M1. Step by step from coding to running each program....................................................................................
    • D1. Check the algorithm implementation in C# language
  • III. Conclusion
  • IV. Reference list
    • Figure 1 : Take 2 liters of water in a saucepan Table of figures
    • Figure 2 : Boiling water
    • Figure 3 : Put the washed vegetables in boiling water
    • Figure 4 : Wait for the vegetables to boil for about 3 minutes, then turn off the heat
    • Figure 5 : Boiled vegetables are served on a plate
    • Figure 6 : The prime of a positive integer
    • Figure 7 : Visual Studio
    • Figure 8 : Platforms: Visual Studio
    • Figure 9 : Flowchart.............................................................................................................................................
    • Figure 10 : Functions
    • Figure 11 : Main method
    • Figure 12 : Debug
    • Figure 13 : test case
    • Figure 14 : Test case

P

II. Content:

1. Algorithm

a. What is the algorithm?

An algorithm is a set of well-defined instructions or procedures that must be followed to perform a particular task or solve a problem. It is a step-by-step process designed to solve a problem or accomplish a specific task. Algorithms can be thought of as recipes or blueprints that provide a clear and concise set of instructions for solving a problem. Algorithms are widely used in all areas of IT. In mathematics and computer science, an algorithm usually refers to a small process that solves an iterative problem. Algorithms are also used as specifications to perform data processing and play a major role in automated systems. In computer science, algorithms are used to solve problems by processing and manipulating data and information. They are used in computer programming and software development to help automate certain processes. This automation can range from simple tasks (e.g. sorting a list of numbers) to more complex tasks (e.g. facial recognition or natural language processing). Algorithms can be executed by humans or machines, and can be written in a variety of programming languages. They can range from simple to complex, and can take into account a wide range of factors and variables depending on the problem they are designed to solve. Overall, algorithms are an essential tool in computer science, mathematics, and many other fields. They provide a systematic way to solve problems and achieve specific goals, and have revolutionized the way we approach complex tasks and analyses.

b. Algorithmic characteristics

There are some main characteristics of algorithms that help identify and distinguish them from other types of problem-solving techniques. These features include: Accuracy, objectivity, universality, clarity, finality. Initially, an algorithm needs to have extremely high "accuracy". It is also the most important, usability and objective element of an algorithm.

In addition, an algorithm is always arranged in a very regular order, with a reasonable arrangement of internal quantities to make the operation much smoother and faster. This is "clarity", expressed in command principle. The "usability" of an algorithm is expressed in terms of flexibility. It is not fixed but flexible, so it can be applied in not only one but many problems with many similar forms. An algorithm, no matter which way it is solved, can only have one answer. That confirms the absolute with the problem results. If the answer is different, the processing process should be reconsidered. This is the "Objectivity" of an algorithm. Finally, "terminality" means the result of an algorithm. Unambiguous: The algorithm must be clear and unambiguous. Each of its steps (or stages), and their inputs/outputs should be clear and lead to only one meaning. Independent: An algorithm should have step- by-step instructions, which should be independent of any programming code. Unambiguous – The algorithm must be clear and unambiguous. Each of its steps (or stages), and their inputs/outputs should be clear and lead to only one meaning. Independent – An algorithm should have step-by-step instructions, which should be independent of any programming code. By complying with these characteristics, the algorithm can be used to solve a wide range of problems in a systematic and efficient manner. These features help ensure that algorithms are reliable, accurate, and efficient, which is essential in a world where complex problems require complex solutions.

c. Algorithm example

Real-life example: Boiled water spinach Step 1: Figure 1: Take 2 liters of water in a saucepan.

Step 4: Step 5: Figure 4: Wait for the vegetables to boil for about 3 minutes, then turn off the heat. Figure 5: Boiled vegetables are served on a plate.

d. Example in math or programming

Figure 6: The prime of a positive integer

2. Steps to build an app:

a. Problem definition

Problem definition is the first step in problem-solving that involves identifying and describing a problem or challenge that needs to be addressed. It is the process of understanding the nature of the problem, analyzing its root cause, and defining specific goals or objectives that need to be achieved to solve the problem.

Program design also includes identifying appropriate problem-solving methods. Programmers need to choose problem-solving methods that are highly flexible and reusable. This ensures that the program is designed efficiently and can be reused under similar circumstances. Finally, the program design needs to ensure the security and reliability of the program. Developers need to identify security risks and put in place appropriate solutions to mitigate these risks. They also need to make sure that the program is highly reliable to ensure that it works consistently and doesn't cause problems.…

c. Program

A program is a sequence of instructions written in a programming language to complete a specific task or set of tasks. Programs are used in software development to create computer applications that are capable of implementing algorithms and performing various functions. Programs are usually written in a high-level programming language and must be translated into machine code (a language understood by the computer) before they can be executed. This translation is usually performed by a compiler or interpreter, which converts high-level code into a form that the computer can understand and execute. Programs can range in complexity from simple scripts that perform basic functions to complex applications that require thousands of lines of code. They are used in many applications, including software development, data processing, machine learning, and more. During the programming process, the use of efficient and optimal programming techniques will help the program to develop quickly and meet the requirements. Dividing the program into modules, using appropriate functions, classes and data structures will help us manage the program easier. In addition to implementing algorithms and performing various functions, programs can also interact with other software components, including operating systems, databases, and other applications. This allows programs to be developed and integrated into larger software systems and performcomplex tasks efficiently. Overall, programs are an essential component of modern software development and provide a powerful tool for creating applications that can perform a variety of tasks and functions.

d. Test and debugging

Writing a program requires not only programming knowledge, but also attention to testing and debugging. The design of tests and debugging is very important to ensure the stability and reliability of the program. Testing and debugging are important steps in the software development process used to ensure that programs are working correctly and free of bugs or errors.

Testing involves running programs through a series of test cases to identify potential problems or bugs. Test cases must cover various scenarios and use cases to ensure that the program works correctly under different conditions. Common types of testing include unit testing, integration testing, system testing, and acceptance testing. When problems or bugs are identified through testing, they must be debugged. Debugging is the process of identifying and isolating bugs or errors in the code and then fixing them. This usually involves using debugging tools and techniques to go through the code and identify the source of the problem. Common debugging techniques include setting breakpoints, checking variable values, and monitoring code execution. Testing and debugging are repeated processes until the program works properly and without errors. It is important to thoroughly test and debug programs to ensure that they work as intended and do not cause unexpected results or problems. Catching and fixing bugs early in development can also save time and resources in the long run by avoiding costly bugs or delays later on.

e. Program documentation

Program documentation refers to written information about a software program that describes how it works, how to use it, and how to maintain it. This document is intended to help users, developers, and other stakeholders understand the program and how to work with it effectively. One of the benefits of program documentation is to help users better understand the program's features and capabilities. Documents can also help users find the information they need quickly and easily. This is useful for new users and non-technical users. In addition, the program's documentation also helps software developers better understand the program's features and functions. This can help them improve and develop a more effective program. It also helps them optimize program implementation and maintenance, reducing time and costs. Program documentation typically includes the following elements:

  1. Overview: General introduction to the program describes its purpose, features and functions.
  2. Installation: Instructions on how to install and set up the program on various platforms or systems.
  3. Instructions for use: Instructions on how to use the program, including how to perform specific tasks and functions.
  4. Technical documentation: Information about the programming languages, design patterns, frameworks, and other specifications used to create the program.
  5. Troubleshooting: List of common problems and errors that may occur when using the program and how to solve them.

maintenance activities also play an important role in developing and improving the program to meet the new needs of users.

g. Introduction to Visual Studio

Visual Studio is an Integrated Development Environment (IDE) developed by Microsoft. Visual Studio provides tools to develop applications for different platforms such as Windows software, mobile applications, web, cloud, and also applications on other platforms. Figure 7: Visual Studio Visual Studio supports many programming languages such as C++, C#, VB.NET, Python, Ruby and JavaScript. This IDE provides a lot of useful features like interface creation, source code management, code auto completion, testing, building, deploying applications and much more. Figure 8: Platforms: Visual Studio Some of the outstanding features of Visual Studio include:

  1. IntelliSense: Automatically complete source code and automatically check for errors while editing code.
  1. Debugger: A tool to help developers find, process, and debug source code.
  2. Git Integration: Supports source code management and version management using Git.
  3. Profiling tools: Allows users to deeply analyze application performance issues.
  4. Azure Tools: Connect to Azure to easily develop and deploy applications in the cloud Visual Studio is one of the most popular IDEs when it comes to software development on the Windows platform, and Microsoft is also developing a free version of Visual Studio Code for macOS and Linux computer users. Visual Studio has become one of the most popular development tools in the software industry, with the supportand contributions of an expanding community of developers worldwide. It provides a powerful environment for cross-platform application development and is customization to meet the specific requirements of each project.

3. Solve problems using algorithms

a. Content of the problem:

Write a program that calculates the sum S = 1/1 + 1/2 + 1/3 + ... + 1/n. The program needs to allow the user to enter the value of n and calculate the sum S according to the given formula.

b. Problem analysis:

To solve this problem, we can follow these steps: Step 1: Ask the user to enter the value of n. Step 2: Use a loop to calculate the value of each component of the sum S. Each loop calculates the value 1/i, where i is an integer ordinal from 1 to n. Step 3: Calculate the sum of S by adding all the 1/i values. Step 4: Display the total S result to the user.

c. Flowchart:

Figure 10: Functions The above code is a source code in C# language to check if a number is prime or not. Here is a detailed explanation of each part of the code:

  1. namespace in C# is used to divide code files into different scopes to make code management and reuse easier. It allows to group together classes, interfaces, abstract classes and other components that have the same operational purpose into the same namespace. In C#, namespace is a keyword used to declare a set of classes, interfaces, and other components of a program. All elements inside a namespace must have the same namespace name.
  2. The Main method is used in every C# program where the program begins execution. It is a static method with a return type of void, i.e. no return value. The Main method takes an arrayof strings (string[] args) as an argument, which is used to pass command line parameters to the program. In the Main method, you can write code to performthe functions of your program. Here, the Main method has no code to perform any function yet, so it is only used to start the C# program. Program functions can be added inside the Main method, or you can create other methods in the Program class to perform their own functionality. +) It declares integer variables i and n and a double s, and initializes s to 0. +) It displays a message asking the user to enter the range of the string.

+) It reads the input using the ReadLine() method and converts it to an integer using the ToInt32() method and assigns the value to n. Figure 11: Main method Main method: This is the main method of the program. In this method, we have the following steps:

  1. Console.WriteLine("Calculate the sum of the sequence of numbers in C#:\n"); : This line displays a message on the console to inform the user about the purpose of the program.
  2. Console.WriteLine(" ----------------------- "); : Print out a dash line to separate the information and the result
  3. Console.WriteLine("\n\n");: Print two blank lines to create space
  4. Console.WriteLine("Enter the number of elements: ");: Ask the user to enter the value of n
  5. n = Convert.ToInt32(Console.ReadLine()); : Read the value of n fromthe keyboard and convert it to integer form.
  6. for (i = 1; i <= n; i++) {} s += 1.0 / i; : Add the value of the expression 1/i to the variable s
  7. Console.WriteLine($"The sum of the sequence S is: {s}\n"); This is a line of C# code used to print the output string of the program. Specifically, this line uses an associative string (interpolated string) to display the value of the variable s (the sum of the string S) on the console.