SlideShare a Scribd company logo
CSC 313 : object oriented
programming
Algorithm and control structures
Miss Jessica Egwom
Topic content
• The concept of an algorithm
• Properties of an algorithm
• Problem-solving strategies
• Implementation strategies
What is an algorithm
 An algorithm is a procedure used for solving a problem or performing
a computation.
• Algorithms act as an exact list of instructions that conduct specified
actions step by step in either hardware- or software-based routines.
• They are a crucial part of computational thinking and problem-solving
in many areas of life, as we use algorithms to accurately execute
tasks.
• An algorithm is simply a set of steps used to complete a specific task.
They're the building blocks for programming
What is algorithm …
A computer algorithm is a computational procedure that takes in a set
of finite inputs and transforms it into output by applying some math &
logic.
• it is simple logic to a problem represented as an informal description
in the form of a flowchart or pseudocode
problem solving and algorithm development
How write an algorithm
• Problem definition – What is to be done?
• Data collection – What do we have to solve the problem? Or inputs.
• Data processing – Understanding what we have or transforming them
into a usable form.
• A logical approach – Employing the collected & created data against
logic to solve.
• Solution – Present the solution in the way you want in a GUI or a
terminal or a diagram or a chart.
• Analyze the problem.
• Restate the problem.
• Write out examples of input and output.
• Break the problem into its component parts.
• Outline a solution in psuedo-code.
How to Design an Algorithm?
• In order to write an algorithm, the following things are needed as a pre-
requisite:
• The problem that is to be solved by this algorithm i.e. clear problem
definition.
• The constraints of the problem must be considered while solving the
problem.
• The input to be taken to solve the problem.
• The output to be expected when the problem is solved.
• The solution to this problem, is within the given constraints.
• Then the algorithm is written with the help of the above parameters such
that it solves the problem
Properties of Algorithm
An algorithm is an effective, efficient method that can use to express the
solution to any problem within a finite amount of space. It is also a well-
defined formal language. There are five properties of an algorithm as given
below.
• It should terminate after a finite time.
• It should produce at least one output.
• It should take zero or more input.
• It should be deterministic means giving the same output for the same input
case.
• Every step in the algorithm must be effective i.e. every step should do
some work
Characteristics of an algorithm
Characteristics of an algorithm
• Input: An algorithm requires some input values. An algorithm can be given
a value other than 0 as input.
• Output: At the end of an algorithm, you will have one or more outcomes.
• Unambiguity: A perfect algorithm is defined as unambiguous, which means
that its instructions should be clear and straightforward.
• Finiteness: An algorithm must be finite. Finiteness in this context means
that the algorithm should have a limited number of instructions, i.e., the
instructions should be countable.
• Effectiveness: Because each instruction in an algorithm affects the overall
process, it should be adequate.
• Language independence: An algorithm must be language-independent,
which means that its instructions can be implemented in any language and
produce the same results.
Factors of an Algorithm
• Modularity: This feature was perfectly designed for the algorithm if
you are given a problem and break it down into small-small modules
or small-small steps, which is a basic definition of an algorithm.
• Correctness: An algorithm's correctness is defined as when the given
inputs produce the desired output, indicating that the algorithm was
designed correctly. An algorithm's analysis has been completed
correctly.
• Maintainability: It means that the algorithm should be designed in a
straightforward, structured way so that when you redefine the
algorithm, no significant changes are made to the algorithm
Factors of an Algorithm II
• Functionality: It takes into account various logical steps to solve a
real-world problem.
• Robustness: Robustness refers to an algorithm's ability to define your
problem clearly.
• User-friendly: If the algorithm is difficult to understand, the designer
will not explain it to the programmer.
• Simplicity: If an algorithm is simple, it is simple to understand.
• Extensibility: Your algorithm should be extensible if another algorithm
designer or programmer wants to use it.
Approaches of an Algorithm (Problem-solving
strategies)
• Brute Force Algorithm
• This algorithm uses the general logic structure to design an algorithm. It is
also called an exhaustive search algorithm because it exhausts all
possibilities to provide the required solution. There are two kinds of such
algorithms:
• Optimizing: Finding all possible solutions to a problem and then selecting
the best one, will terminate if the best solution is known.
• Sacrificing: It will stop as soon as the best solution is found.
• Divide and Conquer
• This is a straightforward algorithm implementation. It enables you to
create an algorithm in a step-by-step fashion. It deconstructs the algorithm
to solve the problem in various ways. It allows you to divide the problem
into different methods, generating valid output for valid input. This
accurate output is forwarded to another function.
• Greedy Algorithm
• This is an algorithm paradigm that makes the best choice possible on
each iteration in the hopes of choosing the best solution. It is simple
to set up and has a shorter execution time. However, there are very
few cases where it is the best solution.
• Branch and Bound Algorithm
• Only integer programming problems can be solved using the branch
and bound algorithm. This method divides all feasible solution sets
into smaller subsets. These subsets are then evaluated further to find
the best solution.
• Randomized Algorithm
• As with a standard algorithm, you have predefined input and output.
Deterministic algorithms have a defined set of information and
required results and follow some described steps. They are more
efficient than non-deterministic algorithms.
• Backtracking
• It is an algorithmic procedure that recursively and discards the
solution if it does not satisfy the constraints of the problem.
Types of Algorithms
• There are two types of algorithms:
• Search Algorithm
• Sort Algorithm
Search Algorithm
• The searching algorithm is of two types:
• Linear Search
• Linear search is a simple algorithm that begins searching for an element or
a value at the beginning of an array and continues until the required
element is not found. It compares the element to be searched with all the
elements in an array; if a match is found, the element index is returned;
otherwise, -1 is returned. This algorithm can be applied to an unsorted list.
• Binary Search
• A binary algorithm is the most basic algorithm, and it searches for
elements very quickly. It is used to find an element in a sorted list. To
implement the binary algorithm, the elements must be stored in
sequential order or sorted. If the elements are stored randomly,
binary search cannot be implemented.
• Sort Algorithm
• Sorting algorithms rearrange elements in an array or a given data
structure in ascending or descending order. The comparison operator
decides the new order of the elements.
• Step 1: Fulfilling the pre-requisites (implementation strategies)
As discussed above, in order to write an algorithm, its pre-requisites
must be fulfilled.
• The problem that is to be solved by this algorithm: Add 3 numbers and print
their sum.
• The constraints of the problem that must be considered while solving the
problem: The numbers must contain only digits and no other characters.
• The input to be taken to solve the problem: The three numbers to be added.
• The output to be expected when the problem is solved: The sum of the
three numbers taken as the input i.e. a single integer value.
• The solution to this problem, in the given constraints: The solution consists
of adding the 3 numbers. It can be done with the help of ‘+’ operator, or bit-
wise, or any other method.
Designing the algorithm
• Step 2: Designing the algorithm
Now let’s design the algorithm with the help of the above pre-
requisites:
Algorithm to add 3 numbers and print their sum:
• START
• Declare 3 integer variables num1, num2 and num3.
• Take the three numbers, to be added, as inputs in variables num1, num2, and
num3 respectively.
• Declare an integer variable sum to store the resultant sum of the 3 numbers.
• Add the 3 numbers and store the result in the variable sum.
• Print the value of the variable sum
• END
problem solving and algorithm development
problem solving and algorithm development
problem solving and algorithm development
problem solving and algorithm development
Control structure

More Related Content

DOCX
Algorithm - A set of rules for solving operations
PDF
DAA INTRO.pdf of design analysis algorithms
PDF
Chapter-1-Introduction-to-Aglorithms.pdf
PPTX
Algorithm in data structure bca .pptx
PPTX
Binary to hexadecimal algorithmic old.pptx
PDF
Lecture 2 role of algorithms in computing
PPTX
What is algorithm
PPTX
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
Algorithm - A set of rules for solving operations
DAA INTRO.pdf of design analysis algorithms
Chapter-1-Introduction-to-Aglorithms.pdf
Algorithm in data structure bca .pptx
Binary to hexadecimal algorithmic old.pptx
Lecture 2 role of algorithms in computing
What is algorithm
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx

Similar to problem solving and algorithm development (20)

PDF
Algorithms.pdf
PPTX
"A short and knowledgeable concept about Algorithm "
PPTX
Design and Analysis of Algorithm ppt for unit one
PPTX
FDFDRERSFDSGAGAFGGFGFGFGFGAFDGFDGFGFFAGFGGDF
PPTX
2. Introduction to Algorithm.pptx
PDF
Introduction to analysis algorithm in computer Science
PDF
introduction to analysis of algorithm in computer science
PDF
UNIT-1-PdjfjfjfjfjfjfjfjfjfjfjPTS-DAA.pdf
PDF
UNIT-1-PPTS-DAA_cofjfjvjcjcncnfncmpressed.pdf
PPT
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
PPT
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
PPT
UNIT 1- Design Analysis of algorithms and its working
PPSX
Ds03 part i algorithms by jyoti lakhani
PDF
Introduction to Algorithms Complexity Analysis
PPT
UNIT-1-PPTS-DAA.ppt
PPT
UNIT-1-PPTS-DAA.ppt
PPT
Introduction to Design Algorithm And Analysis.ppt
PPTX
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
PPTX
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
PDF
Introduction to data structure
Algorithms.pdf
"A short and knowledgeable concept about Algorithm "
Design and Analysis of Algorithm ppt for unit one
FDFDRERSFDSGAGAFGGFGFGFGFGAFDGFDGFGFFAGFGGDF
2. Introduction to Algorithm.pptx
Introduction to analysis algorithm in computer Science
introduction to analysis of algorithm in computer science
UNIT-1-PdjfjfjfjfjfjfjfjfjfjfjPTS-DAA.pdf
UNIT-1-PPTS-DAA_cofjfjvjcjcncnfncmpressed.pdf
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT 1- Design Analysis of algorithms and its working
Ds03 part i algorithms by jyoti lakhani
Introduction to Algorithms Complexity Analysis
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
Introduction to Design Algorithm And Analysis.ppt
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
Introduction to data structure
Ad

Recently uploaded (20)

PPTX
INTRODUCTION TO EVS | Concept of sustainability
PPTX
Microbiology with diagram medical studies .pptx
PDF
. Radiology Case Scenariosssssssssssssss
PDF
The scientific heritage No 166 (166) (2025)
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PPT
protein biochemistry.ppt for university classes
PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PPTX
Cell Membrane: Structure, Composition & Functions
PDF
An interstellar mission to test astrophysical black holes
PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PDF
Placing the Near-Earth Object Impact Probability in Context
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPTX
Introduction to Cardiovascular system_structure and functions-1
PDF
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
PPTX
neck nodes and dissection types and lymph nodes levels
PPTX
2. Earth - The Living Planet earth and life
INTRODUCTION TO EVS | Concept of sustainability
Microbiology with diagram medical studies .pptx
. Radiology Case Scenariosssssssssssssss
The scientific heritage No 166 (166) (2025)
Classification Systems_TAXONOMY_SCIENCE8.pptx
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
bbec55_b34400a7914c42429908233dbd381773.pdf
protein biochemistry.ppt for university classes
7. General Toxicologyfor clinical phrmacy.pptx
Cell Membrane: Structure, Composition & Functions
An interstellar mission to test astrophysical black holes
The KM-GBF monitoring framework – status & key messages.pptx
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
Placing the Near-Earth Object Impact Probability in Context
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Introduction to Cardiovascular system_structure and functions-1
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
neck nodes and dissection types and lymph nodes levels
2. Earth - The Living Planet earth and life
Ad

problem solving and algorithm development

  • 1. CSC 313 : object oriented programming Algorithm and control structures Miss Jessica Egwom
  • 2. Topic content • The concept of an algorithm • Properties of an algorithm • Problem-solving strategies • Implementation strategies
  • 3. What is an algorithm  An algorithm is a procedure used for solving a problem or performing a computation. • Algorithms act as an exact list of instructions that conduct specified actions step by step in either hardware- or software-based routines. • They are a crucial part of computational thinking and problem-solving in many areas of life, as we use algorithms to accurately execute tasks. • An algorithm is simply a set of steps used to complete a specific task. They're the building blocks for programming
  • 4. What is algorithm … A computer algorithm is a computational procedure that takes in a set of finite inputs and transforms it into output by applying some math & logic. • it is simple logic to a problem represented as an informal description in the form of a flowchart or pseudocode
  • 6. How write an algorithm • Problem definition – What is to be done? • Data collection – What do we have to solve the problem? Or inputs. • Data processing – Understanding what we have or transforming them into a usable form. • A logical approach – Employing the collected & created data against logic to solve. • Solution – Present the solution in the way you want in a GUI or a terminal or a diagram or a chart.
  • 7. • Analyze the problem. • Restate the problem. • Write out examples of input and output. • Break the problem into its component parts. • Outline a solution in psuedo-code.
  • 8. How to Design an Algorithm? • In order to write an algorithm, the following things are needed as a pre- requisite: • The problem that is to be solved by this algorithm i.e. clear problem definition. • The constraints of the problem must be considered while solving the problem. • The input to be taken to solve the problem. • The output to be expected when the problem is solved. • The solution to this problem, is within the given constraints. • Then the algorithm is written with the help of the above parameters such that it solves the problem
  • 9. Properties of Algorithm An algorithm is an effective, efficient method that can use to express the solution to any problem within a finite amount of space. It is also a well- defined formal language. There are five properties of an algorithm as given below. • It should terminate after a finite time. • It should produce at least one output. • It should take zero or more input. • It should be deterministic means giving the same output for the same input case. • Every step in the algorithm must be effective i.e. every step should do some work
  • 11. Characteristics of an algorithm • Input: An algorithm requires some input values. An algorithm can be given a value other than 0 as input. • Output: At the end of an algorithm, you will have one or more outcomes. • Unambiguity: A perfect algorithm is defined as unambiguous, which means that its instructions should be clear and straightforward. • Finiteness: An algorithm must be finite. Finiteness in this context means that the algorithm should have a limited number of instructions, i.e., the instructions should be countable. • Effectiveness: Because each instruction in an algorithm affects the overall process, it should be adequate. • Language independence: An algorithm must be language-independent, which means that its instructions can be implemented in any language and produce the same results.
  • 12. Factors of an Algorithm • Modularity: This feature was perfectly designed for the algorithm if you are given a problem and break it down into small-small modules or small-small steps, which is a basic definition of an algorithm. • Correctness: An algorithm's correctness is defined as when the given inputs produce the desired output, indicating that the algorithm was designed correctly. An algorithm's analysis has been completed correctly. • Maintainability: It means that the algorithm should be designed in a straightforward, structured way so that when you redefine the algorithm, no significant changes are made to the algorithm
  • 13. Factors of an Algorithm II • Functionality: It takes into account various logical steps to solve a real-world problem. • Robustness: Robustness refers to an algorithm's ability to define your problem clearly. • User-friendly: If the algorithm is difficult to understand, the designer will not explain it to the programmer. • Simplicity: If an algorithm is simple, it is simple to understand. • Extensibility: Your algorithm should be extensible if another algorithm designer or programmer wants to use it.
  • 14. Approaches of an Algorithm (Problem-solving strategies) • Brute Force Algorithm • This algorithm uses the general logic structure to design an algorithm. It is also called an exhaustive search algorithm because it exhausts all possibilities to provide the required solution. There are two kinds of such algorithms: • Optimizing: Finding all possible solutions to a problem and then selecting the best one, will terminate if the best solution is known. • Sacrificing: It will stop as soon as the best solution is found. • Divide and Conquer • This is a straightforward algorithm implementation. It enables you to create an algorithm in a step-by-step fashion. It deconstructs the algorithm to solve the problem in various ways. It allows you to divide the problem into different methods, generating valid output for valid input. This accurate output is forwarded to another function.
  • 15. • Greedy Algorithm • This is an algorithm paradigm that makes the best choice possible on each iteration in the hopes of choosing the best solution. It is simple to set up and has a shorter execution time. However, there are very few cases where it is the best solution. • Branch and Bound Algorithm • Only integer programming problems can be solved using the branch and bound algorithm. This method divides all feasible solution sets into smaller subsets. These subsets are then evaluated further to find the best solution.
  • 16. • Randomized Algorithm • As with a standard algorithm, you have predefined input and output. Deterministic algorithms have a defined set of information and required results and follow some described steps. They are more efficient than non-deterministic algorithms. • Backtracking • It is an algorithmic procedure that recursively and discards the solution if it does not satisfy the constraints of the problem.
  • 17. Types of Algorithms • There are two types of algorithms: • Search Algorithm • Sort Algorithm Search Algorithm • The searching algorithm is of two types: • Linear Search • Linear search is a simple algorithm that begins searching for an element or a value at the beginning of an array and continues until the required element is not found. It compares the element to be searched with all the elements in an array; if a match is found, the element index is returned; otherwise, -1 is returned. This algorithm can be applied to an unsorted list.
  • 18. • Binary Search • A binary algorithm is the most basic algorithm, and it searches for elements very quickly. It is used to find an element in a sorted list. To implement the binary algorithm, the elements must be stored in sequential order or sorted. If the elements are stored randomly, binary search cannot be implemented. • Sort Algorithm • Sorting algorithms rearrange elements in an array or a given data structure in ascending or descending order. The comparison operator decides the new order of the elements.
  • 19. • Step 1: Fulfilling the pre-requisites (implementation strategies) As discussed above, in order to write an algorithm, its pre-requisites must be fulfilled. • The problem that is to be solved by this algorithm: Add 3 numbers and print their sum. • The constraints of the problem that must be considered while solving the problem: The numbers must contain only digits and no other characters. • The input to be taken to solve the problem: The three numbers to be added. • The output to be expected when the problem is solved: The sum of the three numbers taken as the input i.e. a single integer value. • The solution to this problem, in the given constraints: The solution consists of adding the 3 numbers. It can be done with the help of ‘+’ operator, or bit- wise, or any other method.
  • 20. Designing the algorithm • Step 2: Designing the algorithm Now let’s design the algorithm with the help of the above pre- requisites: Algorithm to add 3 numbers and print their sum: • START • Declare 3 integer variables num1, num2 and num3. • Take the three numbers, to be added, as inputs in variables num1, num2, and num3 respectively. • Declare an integer variable sum to store the resultant sum of the 3 numbers. • Add the 3 numbers and store the result in the variable sum. • Print the value of the variable sum • END