You are on page 1of 12

Higher Nationals in Computing

Programming

ASSIGNMENT

No.1

Learner’s Name: Le Minh Khang

Assessor Name: NGUYEN VAN SON

Class: GCS0903
ID: GCS190749
Assignment due: 2 1 / 6 / 2 0 2 1
Assignment submitted:

ASSIGNMENT 1 FRONT SHEET


Qualification BTEC Level 5 HND Diploma in Computing
Unit number and
Unit 1: Programming
title
Date Received 1st
Submission date 21/6/2021 21/6/2021
submission
Re-submission Date Received 2nd
Date submission
Le Minh
Student Name Student ID GCS190749
Khang

Class GCS0903 Assessor name NGUYEN VAN SON

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:

ASSIGNMENT 1 BRIEF
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and
Unit 1: Programming
Title
Assignment title Problem solving with algorithms
Academic Year
Unit Tutor
Submission
Issue date
date

Submission Format:
Format: The submission is in the form of an individual written report and a
presentation. This should be written in a concise, formal business style using
single spacing and font size 12. You are required to make use of headings,
paragraphs and subsections as appropriate, and all work must be supported
with research and referenced using the Harvard referencing system. Please
also provide a bibliography using the Harvard referencing system.
Submission Students are compulsory to submit the assignment in due date and in a way
requested by the Tutors. The form of submission will be a soft copy in PDF
posted on corresponding course of http://cms.greenwich.edu.vn/
Note: The Assignment must be your own work, and not copied by or from another
student or from
books etc. If you use ideas, quotes or data (such as diagrams) from books, journals or
other sources, you must reference your sources, using the Harvard style. Make sure that
you know how to reference properly, and that understand the guidelines on plagiarism. If
you do not, you definitely get fail
Assignment Brief and Guidance:
Scenario: You have applied for a post as a trainee with a software development
company and have been invited for an interview. You have been asked to demonstrate
your problem solving and basic programming skills. To do this you have to prepare a
report on using algorithms to solve problems.

You need to explain, using examples, how algorithms are used to solve simple
business problems and the steps needed to be followed to produce a working program
solution. You should make clear your assumption about your program. The problems
to be solved will involve basic procedural programming instructions - sequence
instructions (input, output and assignment statements), loops, conditional statements.
Problems should be analysed and designed by the use of flowchart and demonstrated
by the use of modules (procedures) using a menu based program.

Tasks:
• State your simple business problems to be solved.
• Analyse the problem and design the solutions by the use of suitable methods.
• Demonstrate the compilation and running of a menu-based program
• Evaluate how the problem is solved from the designed algorithm to the
execution program written by a specific programming language.

You also need to do a presentation of your work (it should be summary of your report).

Learning Outcomes and Assessment Criteria

Pass Merit Distinction

LO1 Define basic algorithms to carry out an operation and outline the process of
programming an application

P1 Provide a definition of M1 Determine the steps D1 Examine the


what an algorithm is and taken from writing code to implementation of an
outline the process in execution. algorithm in a suitable
building an application. language. Evaluate the
relationship between the
written algorithm and the
code variant.
Table of contents

1. Algorithm and outline the process in building an application.


+ Step 1: Obtain a description of the problem
• This step is much more difficult than it appears. In the following discussion, the word
client refers to someone who wants to find a solution to a problem, and the word
developer refers to someone who finds a way to solve the problem. The developer must
create an algorithm that will solve the client's problem.
• The client is responsible for creating a description of the problem, but this is often the
weakest part of the process. It's quite common for a problem description to suffer from
one or more of the following types of defects: (1) the description relies on unstated
assumptions, (2) the description is ambiguous, (3) the description is incomplete, or (4)
the description has internal contradictions. These defects are seldom due to carelessness
by the client. Instead, they are due to the fact that natural languages (English, French,
Korean, etc.) are rather imprecise. Part of the developer's responsibility is to identify
defects in the description of a problem, and to work with the client to remedy those
defects.

+ Step 2: Analyze the problem.


• The purpose of this step is to determine both the starting and ending points for solving
the problem. This process is analogous to a mathematician determining what is given and
what must be proven. A good problem description makes it easier to perform this step.
• When determining the starting point, we should start by seeking answers to the following
questions:
• What data are available?
• Where is that data?
• What formulas pertain to the problem?
• What rules exist for working with the data?
• What relationships exist among the data values?
• When determining the ending point, we need to describe the characteristics of a
solution. In other words, how will we know when we're done? Asking the following
questions often helps to determine the ending point.
• What new facts will we have?
• What items will have changed?
• What changes will have been made to those items?
• What things will no longer exist?

+ Step 3: Develop a high-level algorithm.


• An algorithm is a plan for solving a problem, but plans come in several levels of detail. It's
usually better to start with a high-level algorithm that includes the major part of a
solution, but leaves the details until later. We can use an everyday example to
demonstrate a high-level algorithm.
• Problem: I need a send a birthday card to my brother, Mark.
• Analysis: I don't have a card. I prefer to buy a card rather than make one myself.
• High-level algorithm:
• Go to a store that sells greeting cards
• Select a card
• Purchase a card
• Mail the card
• This algorithm is satisfactory for daily use, but it lacks details that would have to be added
were a computer to carry out the solution. These details include answers to questions
such as the following.
• "Which store will I visit?"
• "How will I get there: walk, drive, ride my bicycle, take the bus?"
• "What kind of card does Mark like: humorous, sentimental, risqué?"
• These kinds of details are considered in the next step of our process.

+ Step 4: Refine the algorithm by adding more detail.


• high-level algorithm shows the major steps that need to be followed to solve a
problem. Now we need to add details to these steps, but how much detail should we
add? Unfortunately, the answer to this question depends on the situation. We have to
consider who (or what) is going to implement the algorithm and how much that person
(or thing) already knows how to do. If someone is going to purchase Mark's birthday card
on my behalf, my instructions have to be adapted to whether or not that person is
familiar with the stores in the community and how well the purchaser known my
brother's taste in greeting cards.
• When our goal is to develop algorithms that will lead to computer programs, we need to
consider the capabilities of the computer and provide enough detail so that someone
else could use our algorithm to write a computer program that follows the steps in our
algorithm. As with the birthday card problem, we need to adjust the level of detail to
match the ability of the programmer. When in doubt, or when you are learning, it is
better to have too much detail than to have too little.
• Most of our examples will move from a high-level to a detailed algorithm in a single step,
but this is not always reasonable. For larger, more complex problems, it is common to go
through this process several times, developing intermediate level algorithms as we go.
Each time, we add more detail to the previous algorithm, stopping when we see no
benefit to further refinement. This technique of gradually working from a high-level to a
detailed algorithm is often called stepwise refinement.

Stepwise refinement is a process for developing a detailed algorithm by gradually adding detail
to a high-level algorithm.
+ Step 5: Review the algorithm

• The final step is to review the algorithm. What are we looking for? First, we need to
work through the algorithm step by step to determine whether or not it will solve the
original problem. Once we are satisfied that the algorithm does provide a solution to the
problem, we start to look for other things. The following questions are typical of ones
that should be asked whenever we review an algorithm. Asking these questions and
seeking their answers is a good way to develop skills that can be applied to the next
problem.

• Does this algorithm solve a very specific problem or does it solve a more general
problem? If it solves a very specific problem, should it be generalized?

For example, an algorithm that computes the area of a circle having radius 5.2 meters (formula
π*5.22) solves a very specific problem, but an algorithm that computes the area of any circle
(formula π*R2) solves a more general problem.

Can this algorithm be simplified?

One formula for computing the perimeter of a rectangle is:

length + width + length + width


A simpler formula would be:

2.0 * (length + width)


Is this solution similar to the solution to another problem? How are they alike? How are they
different?

For example, consider the following two formulae:

Rectangle area = length * width


Triangle area = 0.5 * base * height
Similarities: Each computes an area. Each multiplies two measurements.

Differences: Different measurements are used. The triangle formula contains 0.5.

Hypothesis: Perhaps every area formula involves multiplying two measurements.

2. The steps taken from writing code to execution


- The general steps for writing a program include the following:
• Understand the problem you are trying to solve: What Are You Trying To Do?. Requireme
and Specification.
• Design a solution : how is it be done?.
• Draw a flow chart : To develop understanding of how a process
is done. To study a process for improvement. To communicate
to others how a process is done. When better communication
is needed between people involved with the same process.
To document a process. When planning a project.
• Write pseudo-code: The purpose of using pseudocode is
an efficient key principle of an algorithm. It is used in planning
an algorithm with sketching out the structure of
the program before the actual coding takes place.
Pseudocode is understood by the programmers of all types.

• Write code: Computer code is essentially a list of instructions that can be run by a
certain program. Most code consists of plain-text documents so they can be used for
many different programs. A unique file extension is given to the document to indicate the
nature of the code. For example, a file created using Python is saved with a .py extension,
like 'myprogram.py.' However, the actual content of the file is still just plain text.

Because most code is in plain text, you can write code using
a basic word processor or text editor. However, it is much more effective
to use a software application that is specifically designed for coding in
a particular language. For example, when you write a document in
plain English, you would use word processor software, which can assist you
with things such as formatting, spelling, and grammar. Similarly,
a code editor provides tools such as syntax checking. Syntax is to code
what spelling and grammar are to writing English.

A code editor is also called an integrated development environment, or IDE.


An IDE is a software application for formatting your code, checking syntax,
as well as running and testing your code. Some IDEs can work with
multiple programming languages, while some are very specific
for only one language.
• Test and debug: Testing is the process to
find bugs and errors. Debugging is the process
to correct the bugs found during testing.
It is the process to identify the failure of implemented code.
It is the process to give the absolution to code failure.
• Test with real-world users: Who is it for:
Mostly users, since their needs are what they're testing. ... And
if done right, real-world testing can mitigate the cost of defects
by channeling user unhappiness into productive bug reports,
and by redirecting the main testing effort to users
who are more willing to take on the cost of finding defects.
• Release program
• Iterate the steps for the next version

3. Examine the implementation of an algorithm in a suitable language.


- An algorithm is a step procedure to solve logical
and mathematical problems. A recipe is a good
example of an algorithm because
it says what must be done, step by step.
3.1. Example : a dish It takes inputs (ingredients) and produces an output (the completed
dish). ... Informally, an algorithm can be called a "list of steps.
3.2. Analysis of an Algorithm.
- A complete analysis of the running time of an
algorithm involves the following steps:
• Implement the algorithm completely.
• Determine the time required for each basic operation.
• Identify unknown quantities that can be used to describe the frequency of
execution of the basic operations.
• Develop a realistic model for the input to the program.
• Analyze the unknown quantities, assuming the modelled input.
• Calculate the total running time by multiplying the time by the frequency for each
operation, then adding all the products.
3.3. Implementation (C#)
• Analysis of quicksort:
public class Quick
{
private static int partition(Comparable[] a, int lo, int hi)
{
int i = lo, j = hi+1;
while (true)
{
while (less(a[++i], a[lo])) if (i == hi) break;
while (less(a[lo], a[--j])) if (j == lo) break;
if (i >= j) break;
exch(a, i, j);
}
exch(a, lo, j);
return j;
}

private static void sort(Comparable[] a, int lo, int hi)


{
if (hi <= lo) return;
int j = partition(a, lo, hi);
sort(a, lo, j-1);
sort(a, j+1, hi);
}
}

4. Evaluate the relationship between the written algorithm and the code variant.
4.1 the written algorithm :
• it uses the structural conventions of a normal programming language, but is
intended for human reading rather than machine reading. Pseudocode typically
omits details that are essential for machine understanding of the algorithm, such
as variable declarations, system-specific code and some subroutines. The
programming language is augmented with natural language description details,
where convenient, or with compact mathematical notation. The purpose of using
pseudocode is that it is easier for people to understand than conventional
programming language code, and that it is an efficient and environment-
independent description of the key principles of an algorithm.

• No standard for pseudocode syntax exists, as a program in pseudocode is not an


executable program
• So the main difference is that the code is a real executable program written with
the need to be executable on a real machine rather than just a mechanism for
communicating with a human.
4.2 the code variant:
• Variant coding is programming ECUs to meet vehicle variants, such as left-hand
drive or right-hand drive. Some states/countries require the automatic activation
of the headlights while driving, what results in another vehicle variant. Variant
coding includes the enabling and disabling of software-driven functions.

5. Referrences:
http://sofia.cs.vt.edu/cs HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html"1114 HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html"-ebooklet/chapter HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html"4 HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html" HYPERLINK "http://sofia.cs.vt.edu/cs1114-
ebooklet/chapter4.html".html .
https://study.com/academy/lesson/how-to-write-a-program-coding-testing-
debugging.html.
https://www.datajob.com/en/definition-automotive/646/variant-
coding#:~:text=Variant%20coding%20is%20programming%20ECUs,disabling%20of%20so
ftware%2Ddriven%20functions.
https://www.quora.com/What-is-the-difference-between-the-written-algorithm-and-
the-code-variant

You might also like