Algorithm and problem solving
Computers are widely used to solve problems. Algorithm design is the key factor in the problem solving. There is no specific method of problem solving. However, a general approach to problem solving can be thought of which is discussed below:
2.3.1 Defining the Problem
Success in solving problems mainly depends on understanding and defining the problem well. This preliminary step of problem solving is called problem definition phase. It involves working out what is to be done and listing the required inputs and expected outputs.
2.3.2 Problem Solving Strategies
There are many problem solving strategies repeatedly used in various problems. We can adopt any of these strategies which may suit the problem and write an efficient algorithm. The three common strategies are:
Divide and conquer strategy - This is the most widely used strategy. According to this strategy, one has to split the original problem into smaller sub-problems which can then be solved without further splitting. Solving a smaller problem gives clarity in understanding the problem and solving the problem. This breaking down method is found in many applications particularly in sorting and searching algorithms.
Dynamic programming - This method is used when the problem needs to be solved using intermediate steps. This method follows the strategy that solutions to larger problems can be had by finding solutions to smaller problems. It is widely used for operation research problems.
Backtracking - One method of problem solving is back tracking in which we start from solution to solve the problem. When the starting point of a solution is not very clear, assume the results that will be obtained and methods are derived from the output.
Breaking the Problem into Sub Problems
For algorithmic problem solving, clearly define the outline of the problem. Take one problem and break it into sub-problems. These sub-problems should be in such a way that the solution to the problem is clear. The communication between sub tasks should be precisely defined while breaking the task. This is the way to do a broader outline of solution for the entire problem. The breaking up of tasks into smaller tasks should be done till the sub tasks can be written as program statements.
The best example for the above is the Banking System. The sub tasks in banking system may include transactions, loans, fixed deposits etc. Each sub task communicates with the other task if necessary.
Data Structure
The data structure is the pattern in which the data should be stored. This is one of the primary factors which define the efficiency of an algorithm. There are no rules stating that the data structure is to be defined in the initial stage or while implementing the algorithm. For some problems, it is possible to define the data structure while designing and for others, it is done during implementing the algorithm.
Effective problem solving depends mainly on the choice of data structure. A small change in data organization can have a significant change in the algorithm. For example, if files are used to store data that has to be in sorted order it leads to inefficient and difficult implementation. Instead if arrays or linked lists are used, the algorithm and implementation will be much more efficient.
The points to be taken care of while choosing a data structure are:
l Data structure should be easily searchable
l Data structure should be easily updated
l Commonly used data structures should be used
l Data structure that supports excessive storage (dynamic storage) if required, should
be taken.
Some of the important data structures are array, linked list, queue, stack and binary tree. However, these topics are beyond the discussion of this unit.
Loops and Termination of Loops
The next step is to write a computational block of sub tasks. Computational statements are input, output statements, iterative blocks (loops), arithmetic expressions and assignment statements.
To construct loops, one must take care of initial conditions, termination condition, and the number of times it has to be executed. To establish an initial condition for a loop, take the smallest sample of the problem, set its value and check the value with all possible conditions.
In the example of adding numbers up to a given input number, the least value of that will be 0. The smallest sample of this problem is sum of number till 0. Let initial condition be "i" and result be "Sum".
i = 0
Sum = 0
The above is the solution if number is 0.
If number is greater than 0 then is initially i=0 and incremented by 1.
Let us take number is 5
While i<=5
{
i = i+1
Sum = sum + i
}
The next step is to set termination condition for loop. There are many ways a termination condition can be set. The simplest termination condition is limiting the iteration to the number of times the process is required.
E.g
For(i =0;i<n;i++)
sum = sum + array_value(i);
The another way of terminating the loop is terminating when some condition becomes false
Eg.
i = 0;
While(i<n)
Sum = sum + array_Value (i);
i++;
For(i =0;i<=5;i++)
sum = sum + i;
Another way of terminating the loop is terminating when some condition becomes false
While(i<=5)
Sum = sum + i;
TutorsGlobe.com Chemical Kinetic-Rates of Reactions Assignment Help-Homework Help by Online Access Chemistry Tutors
tutorsglobe.com wall pressure assignment help-homework help by online plasmolysis tutors
tutorsglobe.com pathogenecity of microorganisms assignment help-homework help by online microbiology tutors
animal kingdom tutorial all along with the key concepts of characteristics of invertebrates, difference invertebrates and vertebrates, phylum protozoa, features of phylum protozoa, categorization of protozoan and amoeba phylum
Avail notable Geophysics Assignment Help at affordable prices and put an end to sleepless nights by scoring A++!
Polyethylene tutorial all along with the key concepts of Classification of Polyethylene, High density polyethylene, Low density polyethylene, Linear low density polyethylene, Production process of Polyethylene, Production process of Polyethylene, High-low pressure production process
herbarium is a collection of pressed, dried plant specimens that mounted on particular sheets, recognized and arranged in the order of an accepted and familiar system of classification.
Fungi tutorial all along with the key concepts of General features of Fungi, Structure of Fungi, Nutrition in Fungi, Fungi Reproduction, Diseases caused by Fungi and Advantages of Fungi to Man
tutorsglobe.com class cestoidea assignment help-homework help by online parasitic helminthes tutors
Theory and lecture notes of Building Blocks of the Flexible-Price Model all along with the key concepts of Potential Output, Real Wages, equilibrium level of real GDP, continue real GDP, composition of real GDP. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Building Blocks of the Flexible-Price Model.
Theory and lecture notes of Dynamic Characteristics III, all along with the key concepts of Inverter Fall Time, Storage Time and Rise-Time. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Dynamic Characteristics III.
Conductimetry tutorial all along with the key concepts of Basic Concepts of Conductance Analysis, Conductimetric measurements, Experimental precautions
Classification of lipids tutorial all along with the key concepts of Acylglycerols, Phosphoacylglycerols, Sphingolipids, Sphingomyelins, Glycosphingolipids, Gangliosides, Waxes, Steroids and Terpenes
tutorsglobe.com catabolism of lipids assignment help-homework help by online energy and enzymes tutors
Theory of Graphs-Assignment help and Homework help having key concepts of Vertices-Edges, Terminology, Directed Graph, Paths, Graph Representation, Connectedness, Subgraphs, Complete Graph and Bipartite Graph
1961881
Questions Asked
3689
Tutors
1488628
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!