100% found this document useful (1 vote)
78 views

Data Structures 1.0

The document discusses various aspects of problem solving and algorithm design such as the basic steps to solve a problem, approaches to algorithm design including top-down and bottom-up, characteristics of algorithms including time and space complexity, common algorithm design approaches like greedy and divide-and-conquer, and characteristics of data structures. It provides definitions of core concepts, lists steps and criteria for different aspects of problem solving and algorithm design, and poses review questions.

Uploaded by

MAHAMA SADIK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
78 views

Data Structures 1.0

The document discusses various aspects of problem solving and algorithm design such as the basic steps to solve a problem, approaches to algorithm design including top-down and bottom-up, characteristics of algorithms including time and space complexity, common algorithm design approaches like greedy and divide-and-conquer, and characteristics of data structures. It provides definitions of core concepts, lists steps and criteria for different aspects of problem solving and algorithm design, and poses review questions.

Uploaded by

MAHAMA SADIK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

PROBLEM SOLVING 4

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
The steps for solving problem are: 6

 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
Approaches to Algorithm Design 13

There are 2 approaches to Algorithm Design

1. Top-Down Approach

2. Bottom-Up Approach
Top-Down Approach 14

Itis 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.

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 15

1. Itenable 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.
Bottom-Up Approach 16

Itis the process of solving the easier parts of a complex


problem individually and finally join each of the
solutions to form the complete solution.
Disadvantages 17

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.
Algorithm Defined 19

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

Algorithms
1. Algorithm must always have one clearly understood starting
point.
2. Algorithm must have one or more clearly understood ending
points.
3. Each operation must be 'effective'.
i.e. can be evaluated, could be easily carried out.
4. Each operation must be 'well defined'.
i.e. clearly understandable, no iota of confusion or ambiguity.
How to Design an Algorithm 26

In designing any algorithm, some important things


should be considered.
These are:
 run-time
 space
 simplicity of algorithm
 input data
Common Approaches for Designing 27

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.
Approaches contn'd 28

Backtrack algorithms: It is a technique that tries several


choices for a solution. If the choice is incorrect,
computation backtracks at the point of choice.
Modular programming approach: Very long programs
are split into groups. This groups are called modules.
Modules are simpler to understand, test and debug. It also
makes it possible to assign sets of modules to programmers
to work and assemble .
Non-recursive algorithm: An algorithm that does not
make use of repetitions and loops.
Criteria for judging an Algorithm
29
 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.
Verification of Algorithm
31

Algorithm verification is the


process of measuring the
performance of the program
with any laid down
standards.
Efficiency analysis of Algorithms 32

An algorithm analysis provides information of how long


or how much space an algorithm will take for solving a
problem.

When the performance of two algorithms are compared


in respect of the time taken and memory required to
solve the same problem, one will certainly be more
efficient than the other.
Space Complexity 33

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.
Time Complexity 34

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.
Frequency Count 35

Frequency count is done using a frequency


counter.
 An electronic device used to count frequency
It measures the number of oscillations or pulses
per second in a repetitive electronic signal. Such
an instrument is sometimes referred to as a
cymometer.
CHARACTERISTICS OF DATA 36
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.
Questions And Answers Session 38
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?

You might also like