You are on page 1of 46

NAME: PHI HÙNG

I D : H U N G N P B H A F 2 0 01 24

C L A S S : P B I T 1710 2

Programing
1. Introduction

2. Algorithm
a. Definition
b. For example
c. Ways to demonstrate Algorithms
d. Characteristics of algorithms
e. Types of algorithm

Out line: 3. Steps in program development


a. Defining the problem
b. Designing the program
c. Coding the program
d. Testing and Debugging
e. Documenting the program
f. Deploying and maintaining the program

4. Applications of algorithms and problem solving

5. Summary
1. Introduction

• A programming language
is a form of language
created according to
specific rules to help
humans communicate
and command
computers to do things.
• Programming is the
foundation of all
computer software today.
2. Algorithm
Definition
For example
Ways to demonstrate algorithms
Characteristics of algorithms
Types of algorithm
a. Definition
An ellipse is used to represent the
o An algorithm is a set of start and end of an algorithm
instructions to solve different
problems in order of steps
with a beginning and an end. Parallelogram to represent inputs
and outputs.

o In mathematics and
computer science, an Rectangles are used to represent the
algorithm usually means a process taken to solve the problem.
small procedure that solves a
recurrent problem.
The rhombus is used to represent
the conditions of the algorithm.
> Problem: Find min, max of two numbers a, b

> Input: a, b

b. For example > Check condition a > b

> If the conclusion is correct a Max/ b Min

> If wrong, conclude b Max/ a Min


c. Ways to demonstrate algorithms

❑ There are 2 common ways to demonstrate algorithms which are:

__Using Pseudocode__ __Using Flowchart__


• Pseudocode

Pseudocode is a concise and informal high-level


description of a computer programming algorithm that
uses the structured conventions of several programming
languages but often leaves out unnecessary details. to
help better understand the algorithm.
• Flowchart

A flowchart is a type of diagram that represents an algorithm


or a process, representing the work steps as different types
of boxes in the order represented by arrows. This diagram
can represent the solution to the problem to be solved step
by step.
Example: Find min, max of two numbers a, b

divide the cases

start and end


Input, output
d. Characteristic of Algorithms
There are 5 characteristic of Algorithms which are:
I. Finiteness: An algorithm should have finite number of steps and it should end after a finite
time.
II. Input: An algorithm may have many inputs or no inputs at all.
III. Output: It should result at least one output.
IV. Definiteness: Each step must be clear, well-defined and precise. There should be no any
ambiguity.
V. Effectiveness: Each step must be simple and should take a finite amount of time.
__Finiteness__

Problem: Create a book management program

➢ The process demonstrates the number of steps for a user


to create a book management program
_______________Input______________

Problem: Create a book management program

➢ At the beginning of the process, the program makes choices.


______________Output_____________

Problem: Create a book management program

➢ The output shows that the result of the process is a complete


book management program.
Definiteness

Problem: Create a book management program

➢ Throughout the process, each step shows exactly the


right cases for the user to choose from.
Effectiveness

Problem: Create a book management program

➢ Throughout the process, every step has been simplified


to make it easier to manage books.
e. Types of algorithm
➢ There are 6 common types of Algorithms which are:

- Recursive Algorithm
- Divide and Conquer Algorithm
- Dynamic Programming Algorithm
- Greedy Algorithm
- Brute Force Algorithm
- Backtracking Algorithm
Recursive Algorithm

A recursive algorithm is an algorithm which calls itself with "smaller (or simpler)" input
values, and which obtains the result for the current input by applying simple operations to the
returned value for the smaller (or simpler) input.

▪ Example: Tower of Hanoi puzzle


Divide and Conquer Algorithm

Divide and Conquer Algorithm is:

▪ Divide the problem into a number of subproblems that are smaller instances of
the same problem.
▪ Conquer the subproblems by solving them recursively. If they are small
enough, solve the subproblems as base cases.
▪ Combine the solutions to the subproblems into the solution for the original
problem.
▪ Example: Divide bread into equal portions
Dynamic Programming Algorithm

Dynamic Programming (DP) is an algorithmic technique for solving an optimization problem by


breaking it down into simpler subproblems and utilizing the fact that the optimal solution to the overall
problem depends upon the optimal solution to its subproblems.
Greedy Algorithm

An algorithm that always takes the best immediate, or local, solution while finding an answer. Greedy
algorithms find the overall, or globally, the optimal solution for some optimization problems, but may find
less-than-optimal solutions for some instances of other problems.
Brute Force Algorithm

In computer science, brute-force search or exhaustive search, also known as generating and test, is a very
general problem-solving technique and algorithmic paradigm that consists of systematically enumerating
all possible candidates for the solution and checking whether each candidate satisfies the problem's
statement.
Example: Crossword puzzles
Backtracking Algorithm

Backtracking is a general algorithm for finding all (or some) solutions to some computational problems,
notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and
abandons a candidate ("backtracks") as soon as it determines that the candidate cannot possibly be
completed to a valid solution.
Example: Eight queens puzzle
3. Steps in program
development
a. Defining the problem

Analyze the problem. The computer user must figure out the problem,
then decide how to resolve the problem - choose a program

Problem : Create a book management software.


b. Designing the program

In this step, the programmer will most likely determine the inputs,
processing activities, and the expected output of the program.

Action: Draw a flowchart showing how to manage books and readers


FLOWCHART
FOR THE
PROBLEM
c. Coding the program

Coding means using the programming language to get the computer to behave as desired. Each
line of the code is a set of instructions for the computer. A set of codes form a script, and a set or
dozens of sets, form a program

o This is possible by coding the program with the use of a specific programming language like:
Java, Pascal, C++, Visual basic etc.

o There are also different types of code like:


- Source code
- Machine code

o While coding, the computer will compile the source code into machine code for the program to
run.
▪ Source code vs Machine code

•Source code: •Machine code:


- High level code writes by
- Low level code
programmer.
understandable by machine.
- Human-readable.
- In machine code format.
- Have to translate for into source
- Generate by compiler.
code for computer to understand.
Source code

❑ Source code is provided to language translator


which converts it into machine understandable
code which called machine code or object code.
Example:

• Problem: Create a book management software.

• Action: Write a source code for the problem using C#


Machine code

Source code
d. Testing and Debugging

•Testing is the process or method of finding errors in a software application or program so that the
application functions according to the end-users..

•Debugging is the action where the development team or a developer implements after receiving the test
report related to the bugs in the software from the testing team.

Error detection
Debugging
Error message
Testing vs Debugging

Testing Debugging
• Can be performed either manually or • Cannot be automated.
with the help of some automation tools.
• After the implementation of the
• Once the coding phase is done, we test case, we can start the Debugging
proceed with the testing process. process.
• Is the presentation of defects. • Is a logical procedure.
e. Documenting the program
❑ This is writing of formal support materials explaining how the program was developed
❑ All stages of the program development should be documented in order to help during
future modification of the program.
❑ There are 2 types of document that the programmer should provide after finishing testing
which are:
• Internal documentation: is written as program comments that cannot be executed by
the program editor. They help programmers to understand the source code
• External documentation: refers to reference materials such as user manuals printed as
booklets. User manuals are common examples of external documentation.
f. Deploying and maintaining the program
• Provide education and support to end users; correct any unanticipated errors that emerge and identify
user-requested modifications.
5. Applications of
algorithms and
problem solving
_________________Problem_________________

➢ Problem: Create a book management program


Designing the program

➢ Action:

- Design program
- Draw a flowchart showing how to manage books and readers
FLOWCHART
FOR THE
PROBLEM
Coding the program

➢ Action: Write a source code for the problem using C#

Run the program

Machine code
source code
5. SUMMARY
Here are the key takeaways:

▪ Algorithm

▪ Steps in program development

▪ Applications of algorithms and problem solving


REFERENCE
•1. WhatIs.com. 2021. What is algorithm? - Definition from WhatIs.com. [online] Available at:
<https://whatis.techtarget.com/definition/algorithm> [Accessed 31 May 2021].
•2. The Economic Times. 2021. What is Pseudocode? Definition of Pseudocode, Pseudocode Meaning - The Economic Times.
[online] Available at: <https://economictimes.indiatimes.com/definition/pseudocode> [Accessed 31 May 2021].
•3. Asq.org. 2021. What is a Flowchart? Process Flow Diagrams & Maps | ASQ. [online] Available at: <https://asq.org/quality-
resources/flowchart> [Accessed 31 May 2021].
•4. Codesansar. 2021. Algorithms (Characteristics, Guidelines & Advantages). [online] Available at:
<https://www.codesansar.com/computer-basics/algorithms.htm> [Accessed 31 May 2021].
•5. Dev, A., 2021. Types of Algorithms and its uses | Coding Ninjas Blog. [online] Coding Ninjas Blog. Available at:
<https://www.codingninjas.com/blog/2020/06/04/types-of-algorithms-and-its-uses/> [Accessed 31 May 2021].
•6. Webartika.manyamfranchise.com. 2021. Atika School - KCSE Computer Studies Projects, News, Notes and Quiz - 4. Program
Development. [online] Available at:
<https://webartika.manyamfranchise.com/notes/computernotes/computerform3/elementary-programming-principles/program-
development> [Accessed 31 May 2021].
•7. GeeksforGeeks. 2021. Difference between Source Code and Object Code - GeeksforGeeks. [online] Available at:
<https://www.geeksforgeeks.org/difference-between-source-code-and-object-
code/#:~:text=Source%20code%20is%20provided%20to,as%20fundamental%20component%20of%20computer.> [Accessed 31
May 2021].
•8. www.javatpoint.com. 2021. Difference Between Testing and Debugging - javatpoint. [online] Available at:
<https://www.javatpoint.com/testing-vs-debugging> [Accessed 31 May 2021].
Thank You

You might also like