0% found this document useful (0 votes)
13 views11 pages

Algorithm Development Strategies

ITS DESCRIBE ABOUYT THEIR TOPICS

Uploaded by

suthiyasri272
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
0% found this document useful (0 votes)
13 views11 pages

Algorithm Development Strategies

ITS DESCRIBE ABOUYT THEIR TOPICS

Uploaded by

suthiyasri272
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

SIMPLE STRATEGIES FOR

DEVELOPING ALGORITHM
SIMPLE STRATEGIES FOR DEVELOPING
ALGORITHM
Step 1: Obtain a description of the problem.
Step 2: Analyze the problem.
Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more
detail.
Step 5: Review the algorithm
Step 1: Obtain a description of the problem.
• This step is much more difficult than it appears.
• In the following discussion, the word client refers
to someone who wants to find a solution to a
problem, The word developer refers to someone
who finds a way to solve the problem.
• The developer must create an algorithm that will
solve the client's problem.
Step 2: Analyze the problem.
• The purpose of this step is to determine both
the starting and ending points for solving the
problem.
• This process is analogous to a mathematician
determining what is given and what must be
proven.
• A good problem description makes it easier to
perform this step.
Step 3: Develop a high-level algorithm.
• An algorithm is a plan for solving a problem, but plans come in
several levels of detail.
• It's usually better to start with a high-level algorithm that includes
the major part of a solution, but leaves the details until later.
• We can use an everyday example to demonstrate a high-level
algorithm.
Problem: I need to send a birthday card to my brother, Mark.
Analysis: I don't have a card. I prefer to buy a card rather
than make one myself.
Example: Go to a store that sells greeting cards Select a card
Purchase a card & mail the card.
Step 4: Refine the algorithm by adding more detail.
A high-level algorithm shows the major steps
that need to be followed to solve a problem.
The technique of gradually working from a
high-level to a detailed algorithm is often called
stepwise refinement.
Stepwise refinement is a process for
developing a detailed algorithm by gradually adding
detail to a high-level algorithm.
Step 5: Review the algorithm.
The final step is to review the algorithm.
First, we need to work through the
algorithm step by step to determine whether
or not it will solve the original problem
Iterative Algorithms

• Understand the problem and termination condition:


Clearly identify the inputs, the desired output, and
the specific condition that will cause the loop to stop.
• Initialize variables: Properly set up all loop control
variables and auxiliary variables (e.g., counters,
sums) before entering the loop.
• Process sequentially: Break the problem down into
small, sequential steps that are performed in each
repetition. The results from one iteration often serve
as the starting point for the next.
• Ensure loop termination: Within the loop,
ensure that the control variables are modified
correctly so that the termination condition will
eventually be met, preventing an infinite loop.
• Tracing for correctness: Tracing the algorithm
step-by-step for a simple input is generally
easier with iteration than recursion due to the
lack of function call overhead and stack
management.
Recursive Algorithms
• Identify the base case: This is the most critical step.
Define the simplest version of the problem that can be
solved directly without further recursion. This condition
acts as the stopping point and prevents infinite
recursion.
• Define the recursive case: Express the larger problem in
terms of a smaller (or simpler) subproblem of the exact
same type.
• Ensure progress towards the base case: The recursive
calls must modify the input in a way that eventually
reaches the base case
• Combine results (if needed): For problems like
sorting (e.g., Merge Sort) or tree traversals, the
results from the smaller recursive subproblems
need to be combined to form the final solution to
the original problem.
• Consider efficiency: Be aware of the overhead
associated with function calls and maintaining the
call stack, which can lead to higher memory usage
and slower execution compared to iterative
solutions.

You might also like