Problem Solving: Steps, Approaches, and Algorithm Design, Lecture notes of Data Structures and Algorithms

An overview of problem-solving techniques, focusing on the basic steps for solving a problem and the top-down and bottom-up approaches to algorithm design. It covers the advantages and disadvantages of each approach, the definition and fundamental characteristics of algorithms, and the importance of time and space complexity, definiteness, finiteness, and correctness in algorithm design.

Typology: Lecture notes

2018/2019

Uploaded on 08/12/2021

jbsadik
jbsadik 🇩🇿

4 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PROBLEM SOLVING
Basic Steps for solving a problem
1. Formulate the problem and decide
data types
2. Identify the steps of computation
3. Identify the decision points
4. Find the result and verify values
4
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Problem Solving: Steps, Approaches, and Algorithm Design and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

PROBLEM SOLVING

Basic Steps for solving a problem

1. Formulate the problem and decide

data types

2. Identify the steps of computation

3. Identify the decision points

4. Find the result and verify values

4

The steps for solving problem

are:

Spend time to understand the problem

Contract the list of variables needed to find

solution

Decide the output layout

Program development

Testing Program

Validating Program

6

Top-Down Approach

It is the technique of breaking down a

problem into various sub tasks needed to be

performed. Sub tasks are further broken

down into separate sub tasks and so on.

14 General Problem Sub task 1 (^) Sub task 2 Sub task 3 Sub sub task 1 Sub sub task 2 Sub sub task 3^ Sub sub task 4

Advantages of Top-Down Approach

1.It enable us to develop and test most

important module.

2.Testing and debugging is easier and efficient.

3. project implementation is smoother and

shorter.

4.This approach is good for detecting and

correcting time delays.

15

Disadvantages

1. There may be difficulty in fitting

together the various parts of the

solution.

2. There may be lack of consistency.

3. This approach is not very much

used.

17

Algorithm Defined

An Algorithm is an ordered sequence of well-stated and effective operations that, when executed, will produce the results. 19

How to Design an Algorithm

 In designing any algorithm, some important things should be considered.  These are:  run-time  space  simplicity of algorithm  input data 26

Common Approaches for Designing Algorithms  Greedy algorithm: It works in steps. Selects the best available option until all options finish. It is widely used.  Divide and Conquer/bottom up approach: The big problem is divided into same type of smaller problems and we design the algorithm to combine the implementation of these smaller problems for implementing the bigger problem.  Randomized algorithm: The feature of random number is used instead of a fixed number. It makes it possible for different input data to be entered to give different results. 27

Criteria for judging an Algorithm  It must work correctly under various conditions.  (^) It must solve the problem according to the given specifications.  (^) It must be clearly written following the top-down or bottom-up strategy.  It must make efficient use of time and resources available.  (^) It must be sufficiently documented so that anybody can understand its implementation.  It must be easy to modify, if required.  (^) It must not be dependent on being run on a particular type of computer. 29

Verification of Algorithm

Algorithm verification is

the process of measuring

the performance of the

program with any laid

down standards.

31

Space Complexity

Space Complexity is the amount computer of main memory it needs to run a program to completion.  (^) The space needed by a program is the sum of the following:  (^) Fixed part- Space for the code, space for simple variables, component variables, space for constants, etc.  (^) Variable part- Space needed by component variables whose size depend on the particular problem instance being solved, and the stack space used by recursive procedures. 33

Time Complexity Time Complexity is the amount of computer time it needs to run a program to completion. If space (memory) is fixed for one algorithm, then only run time will be considered for obtaining the complexity of the algorithm. 34

CHARACTERISTICS OF DATA STRUCTURE  Correctness − Data structure implementation should implement its interface correctly.  Time Complexity − Execution time of operations of data structure must be as small as possible.  Space Complexity − Memory usage of a data structure operation should be as little as possible.  Definiteness - Every step of the algorithm should be clear and well defined.  Finiteness - The algorithm should have finite number of steps. 36

Questions And Answers Session

  1. List the 4 basic step in solving a problem.
  2. List the steps in solving a problem.
  3. List and explain the two types of approach in solving a problem.
  4. List the advantages of the top-down approach
  5. List the list the disadvantages of the bottom-down approach
  6. What is algorithm?
  7. List the fundamental characteristics of algorithm
  8. List the criteria in judging an algorithm.
  9. Define the following Time complexity and Space complexity
  10. List and explain the characteristics of data structure
  11. List and explain the common approaches of algorithm design.
  12. What is frequency count?
  13. What is algorithm analysis? 38