Problem Solving and Algorithms LECTURE 4
Problem Solving and Algorithms LECTURE 4
Algorithm Development
LECTURE 4
Introduction to Problem-Solving in Computing
• What is Problem-Solving?
• In computing, problem-solving refers to the process of designing a solution to
a given problem using a systematic approach.
• It involves analyzing the problem, planning a solution, implementing the
solution, and verifying its correctness.
• Steps in Problem-Solving:
• Problem Identification: Clearly define the problem.
• Analysis: Understand the inputs, processes, and outputs involved.
• Design: Create a plan or solution, often using tools like algorithms, flowcharts,
or pseudocode.
• Implementation: Code the solution in a programming language.
• Testing and Evaluation: Verify that the solution works correctly and
efficiently.
• Maintenance: Update and improve the solution over time as needed.
Algorithm Development
• What is an Algorithm?
• An algorithm is a finite set of well-defined instructions that, when followed,
solve a specific problem.
2. Sum = 0 SUM
3. Get a value
GET VALUE
STOP
pseudocode
what is pseudocode?
A pseudo-code is the English-like representation of the program logic.
It is a sequential step-by-step arrangement of the instructions
to be performed to accomplish a task.
It is an informal and artificial language that helps programmers develop
algorithms.
Example:
1. Write a pseudo code for findings the area of a room.
Solution:
• Begin process
• Input room length
• Input room width
• Multiply length by width to get area
• Print area
• End process
2. Write a Pseudo code for finding the greatest of 3 numbers
represented as A, B, and C.
Solution
• Begin process
• Input A,B,C
• If A>B then big = A
• Else big = B
• If big > C then big = biggest
• Else biggest = C
3. Write an Algorithm to determine a student’s final grade and indicate
whether it is passing or failing. The final grade is calculated as the average
of four marks.
• Solution
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4.
• If average is below 50
Solution for example 3 (below under pseudo code)
• Print “Fail” • Step 1: Input M1, M2, M3, M4
• else • Step 2: Grade ← (M1 + M2 + M3 + M4)/4
• Step 3: If (Grade < 50) then
• Print “Pass” • Print “FALL”
• Print “Pass”
• End it.
Transition from Problem to Algorithm